springmvc RequestBody
@ResponseBody
@RequestMapping
@RequestBody
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
var $btnno2 = $(".mask .btn1 button.ok"); //确认按钮绑定
$btnno2.click(function() {
var nodes = treeObj.getCheckedNodes();
var ids = [];
nodes.forEach(function(data, index, arr) {
if(data){
if(data.floor == '4'){
ids.push(data.id);
}
}
});
var parameter = {};
parameter.ids =ids;
parameter.adminName = $(".popup-content .popup-content-edit .popup-content-edit2").text();
parameter.adminId = $(".popup-content .popup-content-edit .popup-content-edit2").attr("nodeid");
$.ajax({
type : "post",
url : SITE_PATH + "/resourcePush/saveAdminEdit",
data : JSON.stringify(parameter),
dataType : "json",
contentType : 'application/json;charset=UTF-8',
async : true,
success : function(data) {
if(data.status=='success'){
$mask.hide();
$editpopup.hide();
layer.msg(res.message);
//刷新主页面
window.mc.queryCount();
}else{
layer.msg(res.message);
}
},
error : function() {
}
});
})
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ResponseBody
@RequestMapping(value = "/saveAdminEdit", method = RequestMethod.POST)
//public Map<String, Object> saveAdminEdit(@RequestBody List<String> ids, String adminName, String adminId){
public Map<String, Object> saveAdminEdit(@RequestBody Map<String, Object> map){
Map<String, Object> result = new HashMap<>();
@SuppressWarnings("unchecked")
List<String> ids = (List<String>)map.get("ids");
String adminName = ObjectUtils.toString(map.get("adminName"));
String adminId = ObjectUtils.toString(map.get("adminId"));
if(CollectionUtils.isEmpty(ids) || StringUtils.isBlank(adminName) || StringUtils.isBlank(adminId)){
result.put("status", "failed");
result.put("message", "操作失败");
}
result = calendarManagerService.saveAdminEdit(ids, adminName, adminId);
return result;
}