Datatables有他自己的优势,使用起来可以自适应,通过可以快速搜索检索等,但是类型的返回需要一个具体的格式,故看了下相关的参考文档,用java自己实现了下,方便可以直接使用,封装了一个PageResult类,前端可以直接调用ajax获取这个返回类,从而实现自己的前端展示
public class PageResult {
private Integer iTotalRecords;
private Integer iTotalDisplayRecords;
private JSONArray aaData;
public PageResult() {
}
public PageResult(List list) {
setResult(list);
}
publicvoid setResult(List list) {
iTotalRecords = list.size();
iTotalDisplayRecords = list.size();
aaData = JSONArray.parseArray(JSON.toJSONString(list));
}
public Integer getiTotalRecords() {
return iTotalRecords;
}
public void setiTotalRecords(Integer iTotalRecords) {
this.iTotalRecords = iTotalRecords;
}
public Integer getiTotalDisplayRecords() {
return iTotalDisplayRecords;
}
public void setiTotalDisplayRecords(Integer iTotalDisplayRecords) {
this.iTotalDisplayRecords = iTotalDisplayRecords;
}
public JSONArray getAaData() {
return aaData;
}
public void setAaData(JSONArray aaData) {
this.aaData = aaData;
}
}