解决方案 »

  1.   

    xml为什么是<select>标签,而不是<insert>标签?
    另外这样写不对吧:
    MsgSmsInfo msg = null;
    for (int i = 0; i < 6; i++) {
    msg=new MsgSmsInfo();
    msgs.add(msg);

    应该是
    for (int i = 0; i < 6; i++) {
    MsgSmsInfo msg=new MsgSmsInfo();
    msgs.add(msg);
      

  2.   

    collection="msgs"
    msgs  改成 list 就可以了, mybatis中collection的值不代表你传入参数的名字而是一种类型, 官方文档里给出了list和array两种方式
      

  3.   

    如果是数据库是oracle则改成下面的试试。<select id="bathInsertMsgSmsInfo" parameterType="java.util.List">
    insert into 
    msg_smsInfo
    (smsId,receivePhone,sendPhone,msgContent,senderType,sendDate,smsType,aduitType,smsState,bizType,sms_count)
    values 
    <foreach collection="list" item="item" separator="union all"> 
    select (#{item.smsId,jdbcType=VARCHAR},seq_msg_smsInfo.nextval,#{item.receivePhone,jdbcType=VARCHAR},#{item.sendPhone,jdbcType=VARCHAR},
    #{item.msgContent,jdbcType=VARCHAR},#{item.senderType,jdbcType=INTEGER},#{item.sendDate,jdbcType=DATE},
    #{item.smsType,jdbcType=INTEGER},#{item.aduitType,jdbcType=INTEGER},#{item.smsState,jdbcType=INTEGER},
    #{item.bizType,jdbcType=INTEGER},#{item.sms_count,jdbcType=INTEGER}) from dual 
     </foreach>
    </select>
      

  4.   

    楼主是用的什么数据库呢。mysql?
      

  5.   

    正解,如果paramterType为list或者array,那么mybatis会自动将list结构转换为map结构,其中Map的key为list或者array,value为你这里的msgs或者其他,使用时#{list}