Mybatis中mapper.xml参数为0时,参数不能生效

<if test="status != null and status != '' or status ==0">  
    AND status= #{status,jdbcType=INTEGER}  
</if> 

参数为0时,xml中 status !=''会将0排除了,如果只是判断不等null,0是可以传递过去的

上边的是严谨写法

也可以写成这样:

<if test="status != null">  
    AND status= #{status,jdbcType=INTEGER}  
</if> 

 


版权声明:本文为Chasedream_hs原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。