springMVC+spring+mybatis整合过程中遇到的问题

时间:2021-06-24 17:25:56

今天在配置SSM整合的过程中遇到了几个错误,折腾了好久,具体如下

1、java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for

在网上找了好久,最后发现是namespace没写对:

<!-- namespace必须为UserMapper的全称:包名+Mapper接口的名称 -->
<mapper namespace="edu.fjnu.hyf.mapper.UserMapper">

参考博客:http://www.cnblogs.com/skyme/archive/2011/03/14/1983931.html

2、There is no getter for property named 'keyword' in 'class java.lang.String'

代码:

<select id="getUsers" parameterType="String" resultType="User">
select *
from t_user where username like '%${keyword}%' </select>

解决:

将参数名改为_parameter

<select id="getUsers" parameterType="String" resultType="User">
select *
from t_user where username like '%${_parameter}%' </select>

错误原因:参考博客 http://blog.csdn.net/woshixuye/article/details/8820387