1、后端
Map<String,Object> resultMap=service.daochu(map);
net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(resultMap);
response.getWriter().print(fromObject);
response.getWriter().close();
2、前端
$.ajax({
url: basePath + '/Action?method=',
type: 'post',
dataType: 'json',
async:false,
data: {
'shuju':JSON.stringify(obj.data)
},
success: function(obj1) {
}
});
3、后端
//获取到map套list
String valueOf = String.valueOf(map.get("shuju"));
//转换
JSONObject object = JSON.parseObject(valueOf);
//获取list
JSONArray jsonArray = object.getJSONArray(key);
for(int i=0;i<jsonArray.size();i++) {
//jsonObject2相当于map
JSONObject jsonObject2 = jsonArray.getJSONObject(i);
jsonObject2.getString(key);
}