LinkedHashMap 输出实体类数据问题

余糜 发布于 09/18 10:23
阅读 309
收藏 0

LinkedHashMap 可以按put的排序输出值,但实体类数据没有按数据库中的数据显示,下面是我代码和输出的数据格式。这是我要的数据格式:{"code":"0","msg":"","count":11,"data":[{"content":"    data  }]}   , 请问如何能让第二种LinkedHashMap 方式返回数据库数据?

 

第一种方式

JSONObject的输出数据

json:{"count":11,"data":[{"content":"   各位同学,因网络通识课第二次选课时间紧迫,造成少数同学未能按时听课;现特安排两次补课时间:第六周(本周)周五七八节 17512,周六三四节 17512。请选了网络通识课的同学相互转达。 网络通识课包括以下课程:中国近代人物研究、社会科学方法论、文艺美学、儒学与生活、微生物与人类健康、什么是科学、中国经济热点问题研究、生命科学与人类文明、数学思想方法论(系统测试 可以修改)","createtime":{"nanos":0,"time":1600085212000,"minutes":6,"seconds":52,"hours":20,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":21,"title":"通识课公告","username":"admin","status":0},{"content":"10","createtime":{"nanos":0,"time":1600089408000,"minutes":16,"seconds":48,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":10,"title":"10","username":"admin","status":0},{"content":"9","createtime":{"nanos":0,"time":1600089406000,"minutes":16,"seconds":46,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":9,"title":"9","username":"admin","status":0},{"content":"8","createtime":{"nanos":0,"time":1600089386000,"minutes":16,"seconds":26,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":8,"title":"8","username":"admin","status":0},{"content":"7","createtime":{"nanos":0,"time":1600089403000,"minutes":16,"seconds":43,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":7,"title":"7","username":"admin","status":0},{"content":"6","createtime":{"nanos":0,"time":1600089398000,"minutes":16,"seconds":38,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":6,"title":"6","username":"admin","status":0},{"content":"5","createtime":{"nanos":0,"time":1600089400000,"minutes":16,"seconds":40,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":5,"title":"5","username":"admin","status":0},{"content":"4","createtime":{"nanos":0,"time":1600089396000,"minutes":16,"seconds":36,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":4,"title":"4","username":"admin","status":0},{"content":"3","createtime":{"nanos":0,"time":1600089366000,"minutes":16,"seconds":6,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":3,"title":"3","username":"admin","status":0},{"content":"2","createtime":{"nanos":0,"time":1600089330000,"minutes":15,"seconds":30,"hours":21,"month":8,"timezoneOffset":-480,"year":120,"day":1,"date":14},"id":2,"title":"2","username":"admin","status":0}],"code":"0","msg":""}


第二种方式

LinkedHashMap的输出数据

jsonObject:{"code":"0","msg":"","count":11,"data":["cn.com.repairsystem.vo.Notice@6b726f1b","cn.com.repairsystem.vo.Notice@10b6ba95","cn.com.repairsystem.vo.Notice@de31884","cn.com.repairsystem.vo.Notice@dcb1ac3","cn.com.repairsystem.vo.Notice@dc47e7a","cn.com.repairsystem.vo.Notice@db39161","cn.com.repairsystem.vo.Notice@da5ff90","cn.com.repairsystem.vo.Notice@d95554f","cn.com.repairsystem.vo.Notice@d78817e","cn.com.repairsystem.vo.Notice@d58f23d"]}

加载中
0
巴拉迪维
巴拉迪维

给你的类 cn.com.repairsystem.vo.Notice 重写 toString() 方法

返回顶部
顶部