<if test="status!=null and status!=''">
and status = '${status}'
</if>
当我status 传入参数为0的时候(Integer status ),到if 条件时,就不执行,被识别成 空字符串 了。and status != '' 这句去掉。
最近又遇到这个问题了,然后就再去百度了一下,还可以这样写:
<if test="status!=null and status!='' or status == 0">
and status = '${status}'
</if>
这样看来,状态值最好不用0。能不用就不用,从1开始。