ajax代码
function delUserInfo() {
jQuery.ajax({
type : 'POST',
contentType : 'application/json',
url : 'user/delUser',
data : {'id':'12'},
dataType : 'json',
success : function(data) {
alert("删除成功!");
},
error : function(data) {
alert("error")
}
});
}
后台代码
@RequestMapping(value = "/delUser", method = RequestMethod.POST)
@ResponseBody
public Map<String, String> delUser(@RequestParam(value="id", required=true) String id) {
logger.info("捕获到前台传递过来的id:" + id);
UserInfo tmpUserInfo = new UserInfo();
tmpUserInfo.setId(Integer.parseInt(id));
userManage.deleteUser(tmpUserInfo);
Map<String, String> map = new HashMap<String, String>(1);
map.put("success", "true");
return map;
}