后台如何获取ajax传过来的数据

wenyunliuli 2012-03-08 04:01:55
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 和里面的数据。求会的大哥大姐帮忙下。
...全文
1426 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenyunliuli 2012-03-08
  • 打赏
  • 举报
回复
我用的是spring mvc,有人说String ct=request.getParameter("content");这样取,我试了下好像取不到。
潮起潮落 2012-03-08
  • 打赏
  • 举报
回复
get就从querystring中取
post就从form中取
和表单提交和URL请求一样的

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧