controller代码
@SuppressWarnings({ "rawtypes", "unchecked" })
private void insertMsgUser(Map map){
List<String> list=(List) map.get("users");
List<Map> listUser=new ArrayList<Map>();
for(String str:list){
Map<String,Object> maps=new HashMap<String,Object>();
maps.put("userCode", str);
maps.put("msgTitle", map.get("subject"));
maps.put("msgContent", map.get("content"));
maps.put("msgFlag", "0");
maps.put("addTime", System.currentTimeMillis()/1000);
listUser.add(maps);
}
sendmessageBiz.insertTest(listUser);
}
mapper代码
<insert id="insertTest" parameterType="java.util.List">
insert into iqb_inner_message (USER_CODE,MSG_TITLE,MSG_CONTENT,MSG_FLAG,ADD_TIME)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.userCode},#{item.msgTitle},#{item.msgContent},#{item.msgFlag},#{item.addTime})
</foreach>
</insert>