public void query() throws Exception{
List<Account> accounts = accountService.query();
JsonConfig config = new JsonConfig();
config.setExcludes(new String[]{"card","borrows","storeins","accountlevel"});
JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject();
String t = array.fromObject(accounts, config).toString();
System.out.println("this is +=======================+"+accounts.size());
//将结果进行输出
ServletActionContext.getResponse().setContentType("text/html;charset=utf-8");
ServletActionContext.getResponse().getWriter().print(t);
}做法就是将导致死循环的属性删除。
所遇见的错误是:
异常信息如下: There is a cycle in the hierarchy!
版权声明:本文为happy_marvin原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。