java object 前后台转换
jsp:
function createWaring(){
var updateMap = JSON.stringify(updateObj);
document.waring.action = path+"/task/saveWaring.action?updateMap="+updateMap;
document.waring.submit();
}
java:
JSONObject jsonObject = JSONObject.fromObject(vo.getUpdateMap());
List insertlist=new ArrayList();
List updatelist=new ArrayList();
Object c=null;
for(Object key:jsonObject.keySet()){
c=jsonObject.get(key.toString());
WaringModel wm = (WaringModel) JSONObject.toBean((JSONObject) c, WaringModel.class);
if(wm.getWaring_type()==1){
wm.setRole_id(vo.getRole_id());
insertlist.add(wm);
}else{
updatelist.add(wm);
}
}