问题描述:mybatis 之 if test 条件,参数为0时,查询条件未输出。如,当 status值为0(Integer),查询条件没有拼接 and tagtype=0。传入其他值(1,2,3…)都正常
<if test=" null != status and ''!= status">
AND status = #{status}
</if>
如果是这样的字段status(integer)类型的,其默认值为0,如果传递的数值为status=0,那么在这里运行时会自动跳过判断,不进行为0 的查询,所以解决这种问题:我们可以直接进行将不为空串删掉,