XML in foreach

Foreach element properties are mainly collection, item, index, separator, open, close.

collection: represents a collection, data source

item: represents the set of each element

index: in an iterative process is used to represent each iteration to a position

separator: iteration indicates what data symbol as a delimiter

open: What indicates that the statement to begin

close: what is expressed in the end

 

Code Example:

data of the data type 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>

Guess you like

Origin www.cnblogs.com/aaron95/p/11387521.html