美文网首页
mybatis if test 不为空字符串或null

mybatis if test 不为空字符串或null

作者: 墨色尘埃 | 来源:发表于2017-12-08 14:57 被阅读0次

MyBatis 判断条件为等于的问题
在双引号里面再判断不为空,使用单引号

  <if test="productId != null and productId !=''" >  
        and  a.product_id = #{productId,jdbcType=VARCHAR}  
      </if>  
  <if test="type!=null and type!=''">  
        AND type = #{type}  
  </if>  
<if test="extraSql != null and extraSql !=''">
   AND ${extraSql}
</if>

相关文章

网友评论

      本文标题:mybatis if test 不为空字符串或null

      本文链接:https://www.haomeiwen.com/subject/oipeixtx.html