springmvc使用jQuery.datatable时遇到的错误

springmvc使用jQuery.datatable时遇到的错误

 

 1 1正确时返回 josn结果:

 2 

 3 {"aaData":[{"age":31,"id":100000,"name":"wwecs","sex":"man"},{"age":1,"id":100001,"name":"second","sex":"man"},{"age":2,"id":100002,"name":"secondone","sex":"man"},{"age":3,"id":100003,"name":"thridone","sex":"man"},{"age":3,"id":100004,"name":"eeeeee","sex":"man"},{"age":32,"id":100005,"name":"t80aaa","sex":"man"},{"age":100,"id":100006,"name":"test0001","sex":"man"}],"iTotalDisplayRecords":10,"iTotalRecords":10,"sEcho":"1"}

 4 

 5 

 6 2 页面显示处理中(processing),列表空白,其实有返回数据,josn结果:

 7 {"aaData":[{\"age\":31,\"id\":100000,\"name\":\"wwecs\",\"sex\":\"man\"},{\"age\":1,\"id\":100001,\"name\":\"second\",\"sex\":\"man\"},{\"age\":2,\"id\":100002,\"name\":\"secondone\",\"sex\":\"man\"},{\"age\":3,\"id\":100003,\"name\":\"thridone\",\"sex\":\"man\"},{\"age\":3,\"id\":100004,\"name\":\"eeeeee\",\"sex\":\"man\"},{\"age\":32,\"id\":100005,\"name\":\"t80aaa\",\"sex\":\"man\"},{\"age\":100,\"id\":100006,\"name\":\"test0001\",\"sex\":\"man\"}],"iTotalDisplayRecords":10,"iTotalRecords":10,"sEcho":"1"}

 8 

 9 3 同上一致 

10 {"aaData":"[{"age":31,"id":100000,"name":"wwecs","sex":"man"},{"age":1,"id":100001,"name":"second","sex":"man"},{"age":2,"id":100002,"name":"secondone","sex":"man"},{"age":3,"id":100003,"name":"thridone","sex":"man"},{"age":3,"id":100004,"name":"eeeeee","sex":"man"},{"age":32,"id":100005,"name":"t80aaa","sex":"man"},{"age":100,"id":100006,"name":"test0001","sex":"man"}]","iTotalDisplayRecords":10,"iTotalRecords":10,"sEcho":"1"}

11 

12 

13 A1  提示“ DataTables warning (table id = 'example1'): Cannot reinitialise DataTable. To retrieve the DataTables object for this table, pass no arguments or...” 时

14 A2  或者提示“  DataTables warning(table id='example1'):Requested unknown parameter '1' from the data source for row 015 

16 时返回的json结果:

17 

18 {"aaData":"[{\"age\":31,\"id\":100000,\"name\":\"wwecs\",\"sex\":\"man\"},{\"age\":1,\"id\":100001,\"name\":\"second\",\"sex\":\"man\"},{\"age\":2,\"id\":100002,\"name\":\"secondone\",\"sex\":\"man\"},{\"age\":3,\"id\":100003,\"name\":\"thridone\",\"sex\":\"man\"},{\"age\":3,\"id\":100004,\"name\":\"eeeeee\",\"sex\":\"man\"},{\"age\":32,\"id\":100005,\"name\":\"t80aaa\",\"sex\":\"man\"},{\"age\":100,\"id\":100006,\"name\":\"test0001\",\"sex\":\"man\"}]","iTotalDisplayRecords":10,"iTotalRecords":10,"sEcho":"1"}

19 

20  

 

附加去掉   “\”  和“[” "]"的方法:

1             returnstr=returnstr.replaceAll("\\\\", "");

2             returnstr = returnstr.replace(Matcher.quoteReplacement("]\""), "]");

3             returnstr = returnstr.replace(Matcher.quoteReplacement("\"["), "[");

 

 

若转载请标注  :转自 博客园 : http://www.cnblogs.com/rojas/p/4005045.html

你可能感兴趣的:(springMVC)