<foreach item="item" collection="list" separator="and" open="(" close=")" index="">
<bind name="pattern" value="'%' + item + '%'" />
a like #{item}
</foreach>
发现这样的话每次item值都会是list最后一个元素。
把 #{item} 改成 ${item}
ps. 改成 ${item} 的话又要考虑sql注入问题,于是最后没有用bind标签,用了 like '%'||#{param}||'%'..
本文介绍了一种在使用MyBatis动态SQL时遇到的问题,即在使用foreach标签进行元素遍历时,发现每次item值均为集合中最后一个元素的情况及解决办法。通过将#{item}
1114





