0
我正在开发Web应用程序。
我从一个页面发送json字符串到另一个页面。 我已经使用jquery发送发布数据。 在目标页面中,我想检索相同的数据。 但我在那里得到null
值。request.parameter(String)从jquery调用时返回null
我的网页,其中的帖子JSON字符串页面:
$(document).ready(function() {
$.post("./ProfileUser.jsp",{jsonData:jsonstr});
$(location).attr('href',"./ProfileUser.jsp");
});
,并在页面ProfileUser.jsp
<%
String jsonData = request.getParameter("jsonData");
String mobile;
if(jsonData == null) mobile = "something went wrong";
else {
JSONObject j =new JSONObject(jsonData);
mobile = j.getString("mobile");
}
%>
我得到输出Something went wrong
这应该是从数据库中的手机号码。
我应该如何在jsp中获取json数据?
谢谢
谢谢为你的答案。这里有什么是响应的意义。我想在else块中获取json字符串的数据 –
这里'request'参数是什么''response''' request parameter' =>'HttpServletResponse Object' –
我已经试过了,正如你所说的,但问题存在 –