zoukankan      html  css  js  c++  java
  • SSM学习遇到的问题(持续更新)

    SSM学习遇到的问题(持续更新)

    1.问题:使用ajax提交get请求总是返回error

    解决方法:返回格式不正确,dataType如果为json,则需要后台返回的是json值。

    2.问题:无法找到bean:

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

    解决办法:由以上的错误的代码可以看到,我们出现此类bug的原因:找到不到对应的bean,bean注入失败。

    注入失败的原因主要有:

    (1)没有添加注解。例如:@Service @Autowared @Controller 

    (2)错误的注入方法

    (3)对于web.xml中监听器的xml配置错误。

    所以我们要解决此问题,主要检查注解正确的添加,包引入是否正确,以及检查web.xml监听器的配置。 

    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.问题:

    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 



  • 相关阅读:
    Vue $emit()不触发方法的原因
    java 定时任务之一 @Scheduled注解(第一种方法)
    Dubbo的使用及原理浅析.
    Android App 安全的HTTPS 通信
    详解intellij idea搭建SSM框架(spring+maven+mybatis+mysql+junit)
    IDEA 2018集成MyBatis Generator 插件 详解
    自建证书配置HTTPS服务器
    Jsoup(一)Jsoup详解(官方)
    Android使用最小宽度限定符时最小宽度的计算
    可显示行号的log工具
  • 原文地址:https://www.cnblogs.com/carsonwuu/p/10214903.html
Copyright © 2011-2022 走看看