1、List<Object> 循环
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
collection -------- 接收的数组(入参)
index -------- 循环体中的具体对象的序号 item -------- 循环体中的具体对象
open -------- 开始符号 close -------- 关闭符号 separator ------ 分割符号
2、实体类、List<Map> 循环
<foreach collection="students" item="student" close=")" open="(" separator=",">
#{student.xm}
</foreach>
collection -------- 接收的List<student> 实体类List 或者 List<Map>
item -------- 循环体中的student对象或者Map
student.xm -------- 所用对象或者Map 的属性
2019年08月23日
本文详细解析了MyBatis中foreach标签的使用方法,包括如何遍历List<Object>、实体类及List<Map>,并解释了各属性如collection、index、item、open、close和separator的作用。
1万+

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



