这是控制器:
@RequestMapping(value = "saveDetails", method = RequestMethod.POST)
public ModelAndView saveDetails(@ModelAttribute("checkPointDetailsBean") CheckPointDetailsBean checkPointDetailsBean, BindingResult bindingResult) throws ParseException {
System.out.println("ggggggg");
String statusMsg = null;
JSONObject objmJSONObject = new JSONObject();
try {
statusMsg = checkPointDetailsBo.saveDetails(checkPointDetailsBean);
if ("Success".equals(statusMsg)) {
objmJSONObject = getJSONObject(true, statusMsg);
} else {
statusMsg = bindingResult.getNestedPath().concat("savingFailed");
objmJSONObject = getJSONObject(false, statusMsg);
}
} catch (Exception e) {
statusMsg = bindingResult.getNestedPath().concat("savingFailed");
objmJSONObject = getJSONObject(false, statusMsg);
}
ModelAndView mv = new ModelAndView("orgnizationTree");
mv.addObject("orgnizationTree", objmJSONObject);
return mv;
}
private JSONObject getJSONObject(boolean status, String useMaessage) {
JSONObject objmStatusObject = new JSONObject();
JSONObject objmErrorMessageObject = null;
if (status) {
objmStatusObject.put("success", status);
objmErrorMessageObject = new JSONObject();
objmErrorMessageObject.put("reason", useMaessage);
objmStatusObject.accumulate("errors", objmErrorMessageObject);
} else {
objmStatusObject.put("success", false);
objmErrorMessageObject = new JSONObject();
objmErrorMessageObject.put("reason", useMaessage);
objmStatusObject.accumulate("errors", objmErrorMessageObject);
}
return objmStatusObject;
}
这是我的js:
$(document).ready(function() {
$('#CPValueTableContainer').jtable({
title : 'CheckPointValue List',
selecting: "true",
selectingCheckboxes: "true",
multiselect:"true",
type: 'GET',
dataType: 'json',
actions : {
listAction : 'Controller?action=list',
createAction : 'saveDetails',
updateAction : 'Controller?action=update',
deleteAction : 'Controller?action=delete'
},
fields : {
checkPointValue : {
title : 'CheckPointValue',
width : '30%',
key : true,
list : true,
edit : false,
create : true
}
}
});
$('#CPValueTableContainer').jtable('load');
});