mapper.java
int insertList(List<WmContactWelcome> list);
mapper.xml
<insert id="insertList" parameterType="java.util.List">
insert into wm_contact_welcome (company_id, contact_id, `state`,
welcome_id, create_time, update_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.companyId,jdbcType=VARCHAR}, #{item.contactId,jdbcType=INTEGER}, #{item.state,jdbcType=VARCHAR},
#{item.welcomeId,jdbcType=INTEGER}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
1、mapper.java 中参数不加@Param时,foreach的collection值默认用"list",加@Param则与其value相同
2、foreach循环体中的属性前要加item.