SSM學習遇到的問題(持續更新)

SSM學習遇到的問題(持續更新)

1.問題:使用ajax提交get請求老是返回errorjava

解決方法:返回格式不正確,dataType若是爲json,則須要後臺返回的是json值。web

2.問題:沒法找到bean:ajax

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

解決辦法:由以上的錯誤的代碼能夠看到,咱們出現此類bug的緣由:找到不到對應的bean,bean注入失敗。spring

注入失敗的緣由主要有:json

(1)沒有添加註解。例如:@Service @Autowared @Controller app

(2)錯誤的注入方法ide

(3)對於web.xml中監聽器的xml配置錯誤。學習

因此咱們要解決此問題,主要檢查註解正確的添加,包引入是否正確,以及檢查web.xml監聽器的配置。 ui

1 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentListController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.cason.serviceimpl.StudentBeanServiceImpl com.cason.controller.StudentListController.studentBeanImpl; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.cason.serviceimpl.StudentBeanServiceImpl] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
error

 3.問題:this

java.lang.IllegalStateException: Optional int parameter 'id' is not present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.

解決辦法:若是參數是非必須的,則會賦值爲null,所以參數應該是一個object,它才能接受這個null值。而上面代碼參數page 的類型 爲 int,它接受不了null值。

      解決辦法就是將    int  轉換成包裝類型    integer 

相關文章
相關標籤/搜索