mybatis if test 条件参数为0 语句为加入到查询语句中解决

转载: https://blog.csdn.net/TrayLei/article/details/84579212

<if test="guardSpecialPojo.sfzy !=null and guardSpecialPojo.sfzy != '' ">
            <![CDATA[
            AND a.SFZY=#{guardSpecialPojo.sfzy}
             ]]>
        </if>

当传入的guardSpecialPojo.sfzy的值等于0时不追加条件

需要把后面的 and guardSpecialPojo.sfzy != ''  去掉即可

<if test="guardSpecialPojo.sfzy !=null ">
            <![CDATA[
            AND a.SFZY=#{guardSpecialPojo.sfzy}
             ]]>
        </if>

 

posted @ 2020-06-29 16:35  泡沫幻影  阅读(639)  评论(0编辑  收藏  举报