emps = dao.findEmps(); //1.这一步必须 for (Emp emp : emps) { emp.getDept().setEmps(null); } map.put("rows", emps); map.put("total", 14); //2.将map序列化成JSON,SerializerFeature设置成DisableCircularReferenceDetect,打开循环引用检测 String jsonString = JSON.toJSONStringWithDateFormat(map,"yyyy-MM-dd",SerializerFeature.DisableCircularReferenceDetect); writer.write(jsonString);//响应输出 //释放资源,关闭流 writer.flush(); writer.close(); } catch (Exception e) { e.printStackTrace(); }}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。