日期:2014-05-16  浏览次数:20387 次

struts2应用:一个类牵涉到其他类的Json文件
struts2的结果类型中有一种类型为json,它的作用是显示json文件,它通过action中getter方法得到数据作为结果显示出来后,由javascript接收。结果显示形式为:[{xxxx,xxxx,xxxx},{xxx,xxx}]

Json为了加载一个类,由于牵涉到的类太多,使Json文件变得非常臃肿。大家请看:

[{"addtime":"2010-10-11T17:05:55","bid":2,"description":"dsfdsfs","name":"中级班","student":[{"addTime":"2010-09-22T15:55:16","address":{"fid":"19","grops":"shi","id":236,"name":"深圳市","treecode":"4403"},"banji":null,"bianhao":null,"grade":[{"id":"1","mark":89,"stu":null,"sub":{"sid":1,"subName":"语文"}}],"line":"sdfdsfsf","major":"JavaEE","person":"222222222222222222","realname":"张三","sex":"男","uid":16,"writer":"管理员"}]},{"addtime":"2010-10-11T17:05:51","bid":1,"description":"dsfdsf","name":"高级班","student":[{"addTime":"2010-09-29T14:17:50","address":{"fid":"1","grops":"shi","id":35,"name":"市辖区","treecode":"1101"},"banji":null,"bianhao":null,"grade":[{"id":"2","mark":87,"stu":null,"sub":{"sid":1,"subName":"语文"}}],"line":"东城区南池子大街","major":"ASP","person":"465465464646546546","realname":"李四","sex":"男","uid":24,"writer":"管理员"},{"addTime":"2010-09-29T14:23:08","address":{"fid":"2","grops":"shi","id":37,"name":"市辖区","treecode":"1201"},"banji":null,"bianhao":null,"grade":[],"line":"sdfdsfsdfdsf","major":"JavaEE","person":"899989898989898989","realname":"高峰","sex":"女","uid":25,"writer":"管理员"}]},{"addtime":"2010-10-11T15:18:00","bid":4,"description":"dsfsdf","name":"English","student":[{"addTime":"2010-10-11T15:19:59","address":{"fid":"6","grops":"shi","id":73,"name":"沈阳市","treecode":"2101"},"banji":null,"bianhao":null,"grade":[],"line":"sdfgdg","major":"dfgdfgdfg","person":"432423423432423423","realname":"麻子","sex":"女","uid":29,"writer":"管理员"},{"addTime":"2010-10-11T16:44:07","address":{"fid":"22","grops":"shi","id":272,"name":"市辖区","treecode":"5001"},"banji":null,"bianhao":"1286786647828","grade":[{"id":"402881992ba94299012ba9475dbe0004","mark":92,"stu":null,"sub":{"sid":1,"subName":"语文"}},{"id":"402881992ba94299012ba9448de50002","mark":99,"stu":null,"sub":{"sid":2,"subName":"高等数学"}},{"id":"402881992ba94299012ba9452c280003","mark":86,"stu":null,"sub":{"sid":3,"subName":"大学英语"}},{"id":"402881992ba973cf012ba974cf2a0001","mark":69,"stu":null,"sub":{"sid":5,"subName":"大学物理"}},{"id":"402881992ba973cf012ba9754eda0002","mark":99,"stu":null,"sub":{"sid":6,"subName":"理论力学"}}],"line":"fdgfdg","major":"javaEE","person":"143242432422222222","realname":"诸葛亮","sex":"男","uid":35,"writer":"管理员"}]},{"addtime":"2010-10-11T15:18:06","bid":5,"description":"fsdfsf","name":"chinese","student":[{"addTime":"2010-10-11T15:20:18","address":{"fid":"7","grops":"shi","id":87,"name":"长春市","treecode":"2201"},"banji":null,"bianhao":null,"grade":[],"line":"sdfsdf","major":"dsfdgd","person":"423324234234234234","realname":"王五","sex":"男","uid":30,"writer":"管理员"},{"addTime":"2010-10-11T15:22:04","address":{"fid":"10","grops":"shi","id":111,"name":"南京市","treecode":"3201"},"banji":null,"bianhao":null,"grade":[],"line":"dsfdsfds","major":"Asp.net","person":"321313123131231231","realname":"关羽","sex":"男","uid":33,"writer":"管理员"},{"addTime":"2010-10-11T15:22:30","address":{"fid":"9","grops":"shi","id":109,"name":"市辖区","treecode":"3101"},"banji":null,"bianhao":null,"grade":[{"id":"402881992ba94299012ba948a9e50005","mark":69,"stu":null,"sub":{"sid":5,"subName":"大学物理"}},{"id":"402881992ba94299012ba94ba0ee0006","mark":85,"stu":null,"sub":{"sid":1,"subName":"语文"}},{"id":"402881992ba94299012ba94efc4e0007","mark":84,"stu":null,"sub":{"sid":2,"subName":"高等数学"}},{"id":"402881992ba94299012ba94f267b0008","mark":63,"stu":null,"sub":{"sid":3,"subName":"大学英语"}},{"id":"402881992ba94299012ba94f4cee0009","mark":96,"stu":null,"sub":{"sid":4,"subName":"体育"}},{"id":"402881992ba94299012ba94f8f85000a","mark":95,"stu":null,"sub":{"sid":6,"subName":"思想概论"}}],"line":"fdsfd","major":"asp","person":"123123131323132132","realname":"张飞","sex":"女","uid":34,"writer":"管理员"}]},{"addtime":"2010-10-11T15:18:19","bid":6,"description":"sdfsdfsdfsd","name":"japanese","student":[{"addTime":"2010-10-11T