// 注意有空格 与boolean比较//hasRelated 为boolean型
当前位置:   article > 正文

mybatis if 详解

mybatis if

1.if test 比较

字符串比较

      <when test="item.attrDbKey == 'brand_name'.toString()">
        // 
     <when test="item.attrDbKey=='brand_name'">
  • 1
  • 2
  • 3

boolean比较

//hasRelated 为boolean型
 <if test="hasRelated">
  • 1
  • 2

2.if else写法

choose -when -otherwise

           <choose>
                <when test="item.id != null and item.id !=''">
                    #{item.id,jdbcType=CHAR},
                </when>
                <otherwise>
                    '',
                </otherwise>
            </choose>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

补充:

ifnull(exp,v)
当exp为null,用v表示他的值。
sql中exp若表示表字段,值得是该字段对应的值

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/255721
推荐阅读
相关标签