xml中遍历map参数 博客分类: springmvc
xml中遍历map,同遍历将list放在map中一样遍历
不需要的可以移除
param.remove("navTabId");
param.remove("callbackType");
param.remove("menuitemId");
param.put("PROVINCE_AREA_KEY", param.get("provinceAreaKey"));
param.put("CITY_AREA_KEY", param.get("cityAreaKey"));//替换成数据库字段
param.put("COUNTY_AREA_KEY", param.get("country"));
param.remove("provinceAreaKey");
param.remove("cityAreaKey");
param.remove("country");
param.remove("button2");
Map<String,Object> paramm = new HashMap<String,Object>();
paramm.put("param", param);
tbCusFirmChgMapper.saveDataMapFIRM(paramm);
tbCusFirmChgMapper.saveDataMapFIRMCHG(paramm);
直接是paramm中的东西是xml直接可以承接的,如果paramm这个中又有map或者list就要类似下面接收(map传入后,默认只剥开一层)
xml中遍历map
<insert id="saveDataMapFIRMCHG" parameterType="map" >
INSERT INTO TB_CUS_FIRM_CHG
<foreach collection="param.keys" item="k" open="(" close=")" separator=",">
${k}
</foreach>
VALUES
<foreach collection="param.keys" item="k" open="(" close=")" separator=",">
<if test="null != param[k]">
#{param[${k}]}
</if>
</foreach>
</insert>