1.ajax上传map类型数据
var rebate="";
var typeKey="";
var rebateMap = {};
var str ="";
$('.rebateCss').each(function () {
rebate = $(this).val();
typeKey=$(this).attr("typeCate");
rebateMap[typeKey] = rebate;
//主要:map转json字符串放入data
str = JSON.stringify(rebateMap);
});
$.ajax({
url: "merchant_settled!getExamineIsPass.action",
data: {"id": id,"rebate":str},
2.后台解析:
String rebate = request.getParameter("rebate");
JSONObject jb = JSONObject.fromObject(rebate);
Map map = (Map)jb;
Iterator<String> iter = map.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
String value = (String) map.get(key);
String[] typeCate = key.split("_");
for (int i = 0 ; i <typeCate.length ; i++ ) {
Integer param=Integer.parseInt(typeCate[i]);
if(i==0){
//类型id
ProductTypeInfo type=productTypeService.get(param);
}else{
ProductCategoryInfo cate=productCategoryInfoService.get(param);
}
}
}