标签:ons bsp object har sea config 属性 void 数组
baseAction中:
public void write2JsonArray(List<?> list, String[] excludes) throws IOException {
// JsonConfig: 配置转换的json数据中不需要的属性
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(excludes);
// 将转化为json数组
String json = JSONArray.fromObject(list, jsonConfig).toString();
ServletActionContext.getResponse().setContentType("test/json;charset=UTF-8");
ServletActionContext.getResponse().getWriter().print(json);
}
------------------------------------------------------------
动作类中:
List<Area> list = areaService.findAll();
String[] excludes = { "subareas" };
this.write2JsonArray(list, excludes);
标签:ons bsp object har sea config 属性 void 数组
原文地址:http://www.cnblogs.com/xubing520/p/7280749.html