起因:前端展示数据条数不对:InappropriateExpressionException: Inappropriate OGNL expression: (name.length)

或者是 source is null for getProperty(null, "length")

查询条数不对也可能是resultmap使用有误的原因,这里不讨论

异常原因:在自定义mapper.xml中语句出错,

背景:本来数据库有21条数据,结果页面只能展示十条,检查原因发现是因为name和email不为空,时空字符串,导致查询语句加上了and---

原出错代码

 然后我就想着加个条件,改为

 结果就报了这两个错误,可能是因为不能这样写

调整处理思路,在控制器层判断是否是空字符串,如果是就把这两个属性设为null,

 问题解决,这里要注意把""放前面,不然容易爆空指针

----------------------------------------------------------------

补充一种写法

<if test="rname !=null and rname.trim() != ''"> 
and rname like '%${rname}%'
</if>
<if test="routeIntroduce != null and routeIntroduce.trim() != ''"> 
and routeIntroduce like '%${routeIntroduce}%'
</if>

Guess you like

Origin blog.csdn.net/love_yr/article/details/121525677