XML中的foreach

foreach元素的属性主要有 collection,item,index,separator,open,close。

collection:表示集合,数据源

item :表示集合中的每一个元素

index :用于表示在迭代过程中,每次迭代到的位置

separator :表示在迭代时数据以什么符号作为分隔符

open :表示该语句以什么开始

close :表示以什么结束

 

代码示例:

data数据类型为List<Map<String,object>>

update order_info o set o.state=#{state}
<where>
<if test="data!=null">
<foreach collection="data" item="map" index="index" separator=",">
or o.id=#{map.orderId}
</foreach>
</if>
</where>
posted @ 2019-08-21 11:05  Aaronღ  阅读(1517)  评论(0编辑  收藏  举报