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 



  • 相关阅读:
    windows 服务中托管asp.net core
    asp.net core自定义端口
    asp.net core 2.1 部署IIS(win10/win7)
    Centos7 安装Tomcat并运行程序
    centos7 安装java运行环境
    linux(centos7) 常用命令和快捷键 持续验证更新中...
    CentOS7 设置yum源
    dotnet core 入门命令
    二项式系数学习笔记
    [容斥原理][莫比乌斯反演] Codeforces 803F Coprime Subsequences
  • 原文地址:https://www.cnblogs.com/carsonwuu/p/10214903.html
Copyright © 2011-2022 走看看