当我尝试使用:
发送跨域jsonp请求时$.getJSON(url + "?callback=?",
value : 'John',
record : {
value : 'a',
list : [ 1, 2 ]
});
然后我尝试用这样的java servlet来获取它:
public class TestServlet extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String output = request.getParameter("callback")
+ "({\"response\":\"test\"});";
response.setContentType("application/javascript;charset=utf-8");
PrintWriter out = response.getWriter();
out.println(output);
}
}
内部servlet请求字符串具有参数名称:
_=1353482336546
value=John
record[value]=a
如何将请求字符串解析为原始JSON?
我使用嵌入式jetty服务器,我想在JSON字符串上使用“JSON to Object”jetty解析器