Maven+SSM框架下项目开发常见异常及解决方案(二)

本文针对SpringMVC结合MyBatis框架时常见的配置及使用问题进行了详细的解析,包括MyBatis参数类型错误、Spring依赖注入失败、JSP属性访问异常、SQL语法错误及表单验证等问题,并提供了相应的解决思路。
摘要由CSDN通过智能技术生成
Servlet.service() for servlet [SpringMVC] in context with path [/biglovewj] threw exception [Request processing failed; nested exception  is org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.biglovewj.dto.Daily] with root cause java.lang.IllegalArgumentException: Parameter Maps collection does not contain value for com.biglovewj.dto.User

原因: mybatis的mapper文件中,XXXMapper.xml 文件中 增、改等方法参数类型存在错误。
解决方法: 参数类型为 parameterType 而非 parameterMap

Servlet.service() for servlet [SpringMVC] in context with path [/biglovewj] threw exception [Request processing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'diningController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.biglovewj.service.impl.DiningService com.biglovewj.controller.DiningController.service; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.biglovewj.service.impl.DiningService] 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)}] with root cause
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.biglovewj.service.impl.DiningService] 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)}

***原因:***在controller层中,autowired注解下的service层为该层的接口类而非实现类
***解决方法:***查找错误的自动装配类型,将实现类改为接口类
3.

Servlet.service() for servlet jsp threw exception
javax.el.PropertyNotFoundException: Property 'col_linkName' not found on type com.biglovewj.dto.Collectivity

原因: jsp 页面中尝试获取了请求作用域中对象未包含的属性
解决方法: 找到报错的对象的正确属性,并修改jsp中的错误属性
4.

Servlet.service() for servlet [SpringMVC] in context with path [/biglovewj] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'XXX'' at line 

原因: sql语言格式错误(注意如果基本格式没有错误的话,那就看看标点是不是用错了,尤其看最后一个字段值设置完毕后是不是多加了一个逗号)
解决方法: 修改错误的sql语句
5.提交表单信息时报错

type Status report description The request sent by the client was syntactically incorrect.

原因: 提交的表单中的字段可能存在问题,eg:某个字段的数据库类型是int 但是提交的字段中却包含字母、特殊符号等
解决方法: 检查表单中所有字段类型是否对应model层实体类的属性类型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值