http://blog.youkuaiyun.com/javaacmer/article/details/8829635
Struts2.x后台发送json串的Action方法:
看代码:return null
public String dedimensionslist() throws IOException {
String pk_father = pk_dedimensions;
dedimensionslist = this.dedimensions.childrenlist(pk_father);
Map jsonMap = new HashMap();
jsonMap.put("children", dedimensionslist);
jsonMap.put("message", "success");
jsonMap.put("statusCode", 200);
String jsonString = JSONObject.fromObject(jsonMap).toString();
PrintWriter pt =this.getResponse().getWriter();
pt.write(jsonString);
return null;
}
需要的jar包:
json-lib-2.2.2-jdk15.jar
commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-lang.jar
commons-logging-1.1.jar
ezmorph-1.0.4.jar
本文详细介绍了如何在Struts2.x后台通过Action方法发送json串,包括使用jar包、具体代码实现和返回json格式数据的过程。
673

被折叠的 条评论
为什么被折叠?



