在行动:返回JSON对象,提供空数据
//Declaration
JSONObject jObj1 = null;
public JSONObject getjObj1() {
return jObj1;
}
public void setjObj1(JSONObject jObj1) {
this.jObj1 = jObj1;
}
//In Action method
String jsong="{\"cid\":232}";
jObj1 = new JSONObject(jsong);
return Action.SUCCESS
Struts的CFG文件:
<action name="jsonAction" class="jsonAction" method="getJson">
<result type="json" name="success">
<param name="root">jObj1</param>
</result>
</action>
我得到空的结果,当我在JSP控制台中看到
我哪里出错了?谢谢。
你为什么不使用由S2提供的JSON插件? –
[jQuery AJAX的可能的重复 - 问题返回JSON值](http://stackoverflow.com/questions/17093862/jquery-ajax-issue-returning-json-value) –