<if test="null!=state and state!=''">
state=#{state}
</if>
这样state是int类型的数据。这里通过Map传递过来。在这里判断state是否是null和空字符串,当state传过来是0时这个判断是进不了的。
<if test="null!=state and state!='' or state==0">
state=#{state}
</if>
网上有人说这样写,这样写当state为0时是能正确进入的但是当state为空字符串时判断也进入了。
<if test="null!=state and ''!= state">
state=#{state}</if>
所以这样写就可以解决所以问题。