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!