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