我有一個Spring控制器方法是正確的JSON到客戶端返回的對象的集合:春天@ResponseBody JSON - 返回名爲變量
@RequestMapping(value="/admin/rawreads/unknowntags", method=RequestMethod.GET)
public @ResponseBody Collection<RawRead> getRawReadsWithUnknownTag() {
....
}
我試圖整合一個jQuery插件/名爲DataTables的插件。數據表可以處理異步請求來獲取數據,並在我的頁面填充表,但它需要的數據是具有特定名稱「aaData」,而不是當前的格式返回數組:
[{"oid":149452,"date":1233076733000,"readerId":"811210008","recordNo":226,"tagCode":"0103A003C0","reader":null,"guard":null,"checkpoint":null},{"oid":149453,"date":1233076734000,"readerId":"8112100 .... etc]
從數據表文檔數據表建議返回格式:
{
"sEcho": 1,
"iTotalRecords": "n",
"iTotalDisplayRecords": "n",
"aaData": [
[object1][object2].... etc
]
}
我怎樣才能改變我的Java方法,格式數據表返回數據的需求 - 一個命名的數組?
編輯: 試圖把瓦爾成一個HashMap服務器端,變得有點接近我所需要的:
{"iTotalDisplayRecords":3050,"iTotalRecords":3050,"aaData":
[{"oid":149452,"date":1233076733000, ...<snip>},{...}]
}