mybatis 判断内容为空toString

分手后的思念是犯贱 2024-04-06 11:58 160阅读 0赞

在使用mybatis的时候,需要根据内容是否为空,进行过滤,为空的时候,取字段不为空的

判断条件为等于的时候,常量需要加 .toString()

  1. <if test="userItemMenuId != null and userItemMenuId != ''">
  2. and i.user_menu_item_id in
  3. <foreach collection="userItemMenuId.split(',')" open="(" close=")" item="item" separator=",">
  4. #{item}
  5. </foreach>
  6. </if>
  7. <if test="userItemMenuId == null or userItemMenuId == ''.toString()">
  8. and i.user_menu_item_id is not null
  9. </if>

判断空字符串的时候,用’’.toString()

这个数字的处理一样:

  1. <if test="num != null and num == '0'.toString()">
  2. <![CDATA[ and len(num) > 0 ]]>
  3. </if>

发表评论

表情:
评论列表 (有 0 条评论,160人围观)

还没有评论,来说两句吧...

相关阅读