MyBatis if判断条件有特殊需求时的问题

  刚遇到一个问题!!!

  平常写MyBatis if语句时,一般就不等于空并且不等于“ ”即

<if test="pd.shop_id!=null and pd.shop_id!=''>
   and
   shop_id = #{pd.shop_id}
</if>

  但如果这时需要添加一个条件,同时满足三个条件的情况,且最后一个条件是某某等于0,可以这样写

<if test="pd.shop_id!=null and pd.shop_id!=''and pd.super_id=='0'.toString()">
            and
            shop_id = #{pd.shop_id}
        </if>

  加个toString就行了。

参考文章:https://blog.csdn.net/ziany/article/details/79728016

原文地址:https://www.cnblogs.com/yuanmaolin/p/11098701.html