mybatis的xml中if判断的test条件为字符串中包含另一个字符串

直接使用 contains 进行判断

<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>

 

-----------------------------------------------------------------------

个人笔记,仅供参考

posted @ 2020-03-09 20:10  二小子  阅读(17184)  评论(0)    收藏  举报