mybatis 参数为Integer型数据并赋值0时,有这样一个问题:
mybatis.xml中有if判断条件判断参数不为空时,赋值为0的Integer参数被mybatis判断为空,因此不执行<if test="null != item.status and '' != item.status"> and status like concat('%',${item.status},'%') </if>的sql。
所以在做项目时一定要注意,用到mybatis时,避免用0来做值。
解决方法:
加个或者条件 :or status==0
<if test="null != item.status and '' != item.status or status == 0">
and status like concat('%',${item.status},'%')
</if>
如下代码