mybatis的xml中if判断的test条件为字符串中包含另一个字符串
<foreach collection="list" item="item" index="index" separator="AND" open="(" close=")">
<choose>
<when test='item.cname.contains("select") or item.cname.contains("checkbox") or item.cname.contains("date")'>
<if test='item.cname.contains("select") or item.cname.contains("checkbox")'>
find_in_set(#{item.value},base.${item.cname})
</if>
</when>
<otherwise>
base.${item.cname} = #{item.value}
</otherwise>
</choose>
</foreach>
mybatis xml文件中用 if 标签判断字符串是否相等
<if test="delFlag == '2'.toString()">
a.del_flag = #{delFlag}
</if>
<if test=' delFlag == "2" '>
a.del_flag = #{delFlag}
</if>
以上两种 ,都可以实现在 myBatis xml 文件中,实现对字符串的判断。
错误示例
<if test=" delFlag == '2' ">
a.del_flag = #{delFlag}
</if>