select或者updata中,当条件某个值可能传入多个值时,只需要将传入List作为参数传入sql中foreach
select name,age from User where id in
<foreach item="list" collection="list" open="(" close=")" separator="," index="">
${list.id}
</foreach>
;
insert语句中,当传入参数为List时,后台java代码无需for循环每次执行insert语句,只需要将传入List作为参数传入sql中foreach
insert into User(name,age) values
<foreach collection="user" item="user" separator=",">
(#{user.name},#{user.age})
</foreach>
;