如何在servlet中获取jQuery JSON请求参数? [英] How to fetch jQuery JSON request parameters in servlet?
本文介绍了如何在servlet中获取jQuery JSON请求参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下javascript代码:
I have the following javascript code:
var data = {message:"Hi"}
var sendJson = function (){
alert(data);
$.ajax({
url:"./jsonTest",
data: data,
contentType:"application/json",
type:"post",
dataType:"json"
}).success(function(reply) {
alert("successful");
});
}
如何在servlet上获取JSON对象?
How can I fetch the JSON object on my servlet?
我以前试图使用它
request.getParameter("data")
并尝试将其转换为JsonObject,但我一直得到null
.
and trying to convert it to a JsonObject, but I kept getting null
.
推荐答案
@Kebs,
If this isn't figured out yet .. You can find the answer here :)
这篇关于如何在servlet中获取jQuery JSON请求参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文