mapper.xml
<!--批量添加20条随堂作业-->
<insert id="insertBatchExerciseTopic" parameterType="com.admin.model.ExerciseTopic"> INSERT INTO code_dtq_exercise_topic (ID, TEACH_PROGRAM_ID, TOPIC_TYPE, ANSWER_CONTENT, VOICE_TYPE, FLAG) VALUES <foreach collection="exerciseTopicList" item="ExerciseTopic" separator=","> (#{ExerciseTopic.id}, #{ExerciseTopic.teachProgramId}, #{ExerciseTopic.topicType}, #{ExerciseTopic.answerContent}, #{ExerciseTopic.voiceType} </foreach> </insert>foreach collection标签用来遍历传过来的集合 item表示集合每次迭代的别名 每次迭代的的分隔符mapper.java
int insertBatchExerciseTopic(@Param("exerciseTopicList") List<ExerciseTopic> exerciseTopicList);