后台如何获取ajax传过来的数据
var commentVO = {discountId:discountId,content:$("#commentarea").val()};
$.ajax({
url: "/saveComment.json",
data:JSON.stringify(commentVO),
dataType:"json",
contentType: "application/json",
type:"POST" ,
success: function(data) {
$(data).each(function() {
this.createtime = formatDate3(this.createtime);
$("#tmpl_list").tmpl(this).prependTo("#comments_div");
});
$("#contentInput").val("");
}
});
@RequestMapping(value = "/saveComment.json", method = RequestMethod.POST)
public
@ResponseBody
UserComment saveComment(@RequestBody UserComment userComment, HttpServletRequest request) throws JSONException {
logger.debug(userComment);
FrontUser user = getUser(request);
if (user == null) {
userComment.setUserId("0");
userComment.setUserName("匿名用户");
} else {
userComment.setUserId(user.getId());
userComment.setUserName(user.getName());
}
UserComment result = commentManager.saveComment(userComment);
FrontUserVO frontUserVO = new FrontUserVO(user);
result.setUserVO(frontUserVO);
return result;
}
请问在后台怎么取得commentVO 和里面的数据。求会的大哥大姐帮忙下。
------解决方案--------------------
get就从querystring中取
post就从form中取
和表单提交和URL请求一样的