在写筛选查询时,参数为对象,显示此参数找不到,报这个错误,几经研究查询
ERROR o.jeecg.common.exception.JeecgBootExceptionHandler:79 - nested exception is org.apache.ibatis.binding.BindingException: Parameter 'email' not found. Available parameters are [pageNo, pageSize, param3, user, userId, param4, param1, param2]
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'email' not found. Available parameters are [pageNo, pageSize, param3, user, userId, param4, param1, param2]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy134.selectList(Unknown Source)
xml文件是这样子写的,是因为没有取到值,传的是对象应为对象.字段
<if test="email!=null and email!=''">
AND u.email like concat("%",#{email},"%")
</if>
<if test="phone!=null and phone!=''">
AND u.phone =like concat("%",#{phone},"%")
</if>
改成这样子就可以了:
<if test="user.email!=null and user.email!=''">
AND u.email like concat("%",#{user.email},"%")
</if>
<if test="user.phone!=null and user.phone!=''">
AND u.phone =like concat("%",#{user.phone},"%")
</if>