mybatis 判断 list 是否为空进行 foreach 遍历,这里记录一下
1、mapper 层代码
List<Check> findList(@Param("ids")List<Integer> ids);
2、xml代码
<if test="ids != null and ids.size() > 0">
and id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
至此完
本文详细讲解了如何在Mybatis中使用iftest条件判断List非空,并通过foreach遍历。重点展示了XML配置文件中的具体代码实现。
1103

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



