INSERT INTO studentinfo (stuNo,stuName,stuSex,stuTel,stuAddress,classNo) VALUES
(100101,'张三','男','18792505832','西安','1001'),
(100102,'吴晨晞','女','18792505832','西安','1001'),
(100103,'吴洁','女','18792505832','西安','1001'),
(100201,'余旭涛','男','18792505832','西安','1002'),
(100202,'徐浩宸','男','18792505832','西安','1002')

解决方案 »

  1.   

    建立一个Student类然后存到集合里再循环出来就好了啊
      

  2.   

    foreach标签不就行了
      

  3.   

    举例:
    实体类TrainRecord结构如下:
     
    Java代码  
    public class TrainRecord implements Serializable {  
      
        private static final long serialVersionUID = -1206960462117924923L;  
      
        private long id;  
      
        private long activityId;  
      
        private long empId;  
      
        private int flag;  
      
        private String addTime;  
              
        //setter and getter   
          
    }   
    对应的mapper.xml中定义如下:
     
    Xml代码  <resultMap type="TrainRecord" id="trainRecordResultMap">  
        <id column="id" property="id" jdbcType="BIGINT" />  
        <result column="add_time" property="addTime" jdbcType="VARCHAR" />  
        <result column="emp_id" property="empId" jdbcType="BIGINT" />  
        <result column="activity_id" property="activityId" jdbcType="BIGINT" />  
        <result column="flag" property="status" jdbcType="VARCHAR" />  
    </resultMap>  
    mapper.xml中批量插入方法的定义如下:
    <insert id="addTrainRecordBatch" useGeneratedKeys="true" parameterType="java.util.List">  
        <selectKey resultType="long" keyProperty="id" order="AFTER">  
            SELECT  
            LAST_INSERT_ID()  
        </selectKey>  
        insert into t_train_record (add_time,emp_id,activity_id,flag)   
        values  
        <foreach collection="list" item="item" index="index" separator="," >  
            (#{item.addTime},#{item.empId},#{item.activityId},#{item.flag})  
        </foreach>  
    </insert>