mybatis 判断内容为空toString
在使用mybatis的时候,需要根据内容是否为空,进行过滤,为空的时候,取字段不为空的
判断条件为等于的时候,常量需要加 .toString()
<if test="userItemMenuId != null and userItemMenuId != ''">
and i.user_menu_item_id in
<foreach collection="userItemMenuId.split(',')" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</if>
<if test="userItemMenuId == null or userItemMenuId == ''.toString()">
and i.user_menu_item_id is not null
</if>
判断空字符串的时候,用’’.toString()
这个数字的处理一样:
<if test="num != null and num == '0'.toString()">
<![CDATA[ and len(num) > 0 ]]>
</if>
还没有评论,来说两句吧...