随笔记录。亲测可用
1.批量插入
mapper
int insertBrandBusinessByExcel(List<Label> list);
.xml
<!--批量插入-->
<insert id="insertBrandBusinessByExcel" parameterType="com.mj.linen.pojo.label.Label">
insert into tb_label (ecp,pid,ehco)<!--对应字段-->
values
<foreach collection="list" separator="," item="label"><!--循环插入,item:别名-->
(#{label.ecp,jdbcType=VARCHAR},#{label.pid,jdbcType=INTEGER},#{label.ehco,jdbcType=VARCHAR})
</foreach>
</insert>
controller:
/**
* 批量入库
* @param list
* @param pid
* @return
*/
@PostMapping("/insertAll")//@RequestParam 不写会报List错误
public Object insertLabel(@RequestParam("list")List<Label> list,String ehco,int pid,String user){
postman:

相应事物层控制层就不写了都是相应的调用(我是测试),或处理下逻辑。