後台代碼:
Map map = new HashMap();
map.put("tableName", "engage_major_release");
map.put("fields", "*");
map.put("orderField", "mre_id");
map.put("sqlwhere", "");
map.put("pageSize", 2);
map.put("pageIndex", 1);
map.put("orderType", 0);
List> list = this.zpBiz.queryEngage(map);
JsonConfig config = new JsonConfig();
//提供對實體中sql.Date的格式處理
config.registerJsonValueProcessor(java.sql.Date.class, new DateValueProcessor());
JSONArray json = JSONArray.fromObject(list,config);
System.out.println(json);
System.out.println(list.get(0).get("regist_time"));
response.setContentType("text/json;charset=UTF-8");
PrintWriter outPrintWriter = response.getWriter();
outPrintWriter.print(json);
outPrintWriter.close();
return null;
發最後生成的json字符串看看
你那兩列配置的列值應該是json對象,對象調用toString後得到的就是你那個內容
你要給時間列配置formatter,返回這個列值對象的屬性
formatter:function(value,row,index){return value.對象屬性值}