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都可以

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

猜你喜欢

转载自www.cnblogs.com/mosakashaka/p/12609270.html