首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

后台怎么获取ajax传过来的数据

2012-04-17 
后台如何获取ajax传过来的数据var commentVO {discountId:discountId,content:$(#commentarea).val()}

后台如何获取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请求一样的

热点排行