mybatis list--foreach 循环
1.对象循环插入(List<ActLabelGroupRel>)
实体类ActLabelGroupRel:
private String labelGroupId ; private String labelId ; private String labelName ;
dao层代码:
void insertActLabelGroupRel(@Param("listData") List<ActLabelGroupRel> listData);
xml文件代码:
<insert id="insertActLabelGroupRel"> insert into act_label_group_rel values <foreach collection="listData" item="param" separator="," close=";"> (#{param.labelGroupId}, #{param.labelId}, #{param.labelName}) </foreach> </insert>