Mybatis中判断集合的size,可以用下面的方法来做。
<if test="null != staffCodeList and
staffCodeList.size > 0">
and gui.USER_CODE not in
<foreach collection="staffCodeList" item="staffCode" open="(" separator="," close=")">
#{staffCode}
</foreach>
</if>
and gui.USER_CODE not in
<foreach collection="staffCodeList" item="staffCode" open="(" separator="," close=")">
#{staffCode}
</foreach>
</if>
MyBatis集合判空
本文介绍了一种在MyBatis中判断集合是否为空的方法,通过XML映射文件中的if标签结合OGNL表达式实现对集合的判断,并使用foreach标签进行非空集合元素的遍历。
6101

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



