我的是这样写的: 
dao类里面:session.insert("insertTaskDetail", taskDeList); 
.xml里面:<insert id="insertTaskDetail"> <selectKey resultType="int" order="AFTER" keyProperty="taskDetailId"> 
SELECT LAST_INSERT_ID() AS taskDetailId 
</selectKey> INSERT INTO `tbl_msg_task_detail` ( 'task_Detail_Id', 
`task_Id` , 
`from_UserId` , 
`to_UserId` , 
`to_User_Longitude` , 
'to_User_Latitude', 
'msg_Content', 
'msg_Order', 
'task_Detail_Status', 
'create_date' 

VALUES 
<foreach collection="taskDeList" item="item" index="index" separator=","> 
(taskDetailId, 
#{item.taskId}, 
#{item.fromUserId}, 
#{item.toUserId}, 
#{item.toUserLongitude}), 
#{item.toUserLatitude}, 
#{item.msgContent}, 
'', 
'0', 
CURRENT_TIMESTAMP) 
</foreach> 
</insert> 但是添加的时候报错了,说是:Cause: org.apache.ibatis.mapping.SqlMapperException: The expression 'taskDeList' evaluated to a null value. 
我的传入集合为null,这是怎么回事啊!

解决方案 »

  1.   

    <insert id="insertTaskDetail" parameterType="com.……">  
      

  2.   


    我试了,加了parameterType="java.util.List"这个属性,可还是报同样的错误啊?
      

  3.   

    解决了,放到map里就好了,不知道为什么
    Map<String, Object> paraMap = new HashMap<String, Object>();
      

  4.   

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