如何在.jsp文件中接收post请求中Ajax发送的数据

时间:2017-01-30 07:25:38

标签: jquery jsp



$.ajax({
  type: "get",
  url: "serverHistoryView.jsp",
  data: {
    "serverName": serverName,
    "startDate": startDate,
    "endDate": endDate
  },
  contentType: "application/html; charset=utf-8",

  success: function(data) {

    $("#response").html("");
    $("#response").html(data);
  }
});

I can get the data on JSP 
String serverName=request.getParameter("serverName");




但是当我试图通过post request做同样的事情时。我无法在serverHistoryView.jsp上获取ajax数据。我该怎么办?

1 个答案:

答案 0 :(得分:1)

尝试使用" data.d"而不是"数据"

$.ajax({
  type: "get",
  url: "serverHistoryView.jsp",
  data: {
    "serverName": serverName,
    "startDate": startDate,
    "endDate": endDate
  },
  contentType: "application/html; charset=utf-8",

  success: function(data) {

    $("#response").html("");
    $("#response").html(data.d);
  }
});