首页新闻找找看学习计划

fastjson关闭重复无效

0
悬赏园豆:50 [已解决问题] 解决于 2018-11-29 14:32
scoreList = base.findAll("from ScoreVo");
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
JSONObject json = new JSONObject();
json.put("code",0);
json.put("msg","");
json.put("count",0);
json.put("data", scoreList);
JSON.toJSONString(scoreList, SerializerFeature.DisableCircularReferenceDetect);
System.out.println(json.toJSONString());
out.print(json.toJSONString());
out.flush();
out.close();

新手,使用了struts2和Hibernate,然后json格式输出就一直有问题,关闭重复检测也没有用,请大佬帮我看一下是什么问题

{"code":0,"count":0,"data":[{"course":{"courseId":1,"courseName":"C语言","credit":4},"courseId":1,"score":99,"scoreId":3,"stud":{"age":17,"clas":{"clasId":2,"clasName":"17秋2班","studs":[]},"clasId":2,"remark":"天方夜谭谷雨茶","sex":"女","studId":17010002,"studName":"晓晓"},"studId":17010002},{"course":{"courseId":4,"courseName":"JSP","credit":6},"courseId":4,"score":66,"scoreId":4,"stud":{"age":19,"clas":{"clasId":1,"clasName":"17秋1班","studs":[]},"clasId":1,"remark":"电饭锅和监控","sex":"男","studId":17010004,"studName":"李华"},"studId":17010004},{"course":{"courseId":2,"courseName":"SQL2014","credit":6},"courseId":2,"score":88,"scoreId":5,"stud":{"$ref":"$.data[4].stud"},"studId":17010002},{"course":{"courseId":3,"courseName":"JAVA","credit":8},"courseId":3,"score":78,"scoreId":7,"stud":{"$ref":"$.data[4].stud"},"studId":17010002},{"course":{"courseId":5,"courseName":"SSH","credit":10},"courseId":5,"score":45,"scoreId":8,"stud":{"age":24,"clas":{"$ref":"$.data[4].stud.clas"},"clasId":1,"remark":"3","sex":"男","studId":17010001,"studName":"东方饭店"},"studId":17010001}],"msg":""}

lss.24的主页 lss.24 | 初学一级 | 园豆:154
提问于:2018-07-10 16:56
< >
分享
最佳答案
0

fastjson关闭??我记得流是需要关闭的吧,博主能重新叙述一下你得问题吗

收获园豆:50
番茄先生 | 小虾三级 |园豆:867 | 2018-07-10 17:00

抱歉,标题写错了,是关闭重复检测无效

lss.24 | 园豆:154 (初学一级) | 2018-07-10 17:06

@lss.24: 你这个json串没看出有什么问题,关闭重复检测无效能否叙述一下,或者错误信息贴出来

番茄先生 | 园豆:867 (小虾三级) | 2018-07-10 17:12
其他回答(1)
0

public static void OutJson(List list,int count){
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("UTF-8");
try {
PrintWriter out = response.getWriter();
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", 0);
json.put("count", count);
json.put("data", list);
String str = json.toJSONString(json,SerializerFeature.DisableCircularReferenceDetect);
System.out.println(str);
out.print(str);
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

lss.24 | 园豆:154 (初学一级) | 2018-11-29 14:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册