Mybatis的XML中数字不为空的判断

status是Integer类型。

一开始传入0的时候,发现这个判断语句走不进去,但是传1是好的:

    <if test="status != null and status != ''">
        and c.status = #{status}
    </if>

后来修改为

    <if test="status != null">
        and c.status = #{status}
    </if>

则0和1都可以

所以数字判断的时候,应该是只要判断非空就可以。

posted @ 2020-03-31 22:43  mosakashaka  阅读(2343)  评论(0编辑  收藏  举报