<if test="cutList != null">
<if test="isInterrupt == '1'.toString() ">
AND A.basic_id IN (
<foreach collection="cutList" item="item" index="index" separator="," >
#{item}
</foreach>
)
</if>
<if test="isInterrupt == '0'.toString() ">
AND A.basic_id NOT IN (
<foreach collection="cutList" item="item" index="index" separator="," >
#{item}
</foreach>
)
</if>
</if>
1. Mybatis中 if test 判断数值字符串注意项
<if test="isInterrupt == '1'.toString() ">
2. Mybatis中遍历list入参
<if test="isInterrupt == '1'.toString() ">
AND A.basic_id IN (
<foreach collection="cutList" item="item" index="index" separator="," >
#{item}
</foreach>
)
</if>collection为需遍历数组,item为当前循环的变量,index为计数器,separator=","指循环一次则以“,”分隔
这里IN 的()可以直接用open="(" close=")"属性设置
<foreach collection="cutList" item="item" index="index" open="(" close=")" separator="," >
1333




被折叠的 条评论
为什么被折叠?



