mytatis将Integer等于0识别成空字符串

在进行myBatis条件查询的时候,会有如下操作:

<if test="delFlag !=null and delFlag != ''">
and t.del_flag = #{delFlag}
</if>

这样的场景只针对字符串条件查询,如果参数delFlag是Integer类型,且等于0的时候,会识别成空字符串,那样就不会进这个条件查询了。

解决方案如下

<if test="delFlag !=null">
and t.del_flag = #{delFlag}
</if>

原文地址:https://www.cnblogs.com/mark8080/p/6251291.html