Learn to use the bootstrap table when paging the client, with the help of a friend, find the document http://bootstrap-table.wenzhixin.net.cn/examples/                &NBSP
Found the number of limit per page that was uploaded to the background, and the number of records started offset.             &NBSP
Start encapsulation, share my code, from bootstrap Table gets the page numbers and pages, and gives the background processing.
$ (' #table '). bootstraptable ({url: ' <%=path%>/feedlist.cqzk ', Striped:true, Pagination:true, PageList: [3,
5,20], Pagesize:3, pagenumber:1, sidepagination: ' Server ',//set to server-side paging columns: [{field: ' titles ', Title: ' Title '
}, {field: ' Creattime ', title: ' Time '}]}; @RequestMapping (value = "/FEEDLIST.CQZK") @ResponseBody public String url_ad1 (httpservletrequest request,bootpage page ) throws servletexception,ioexception,runtimeexception{@SuppressWarnings ("unchecked")//List<feedback> List
= Feedbackdao.find ("from Feedback");
Bootpage pager = Feedbackdao.getbypage ("From Feedback", page,null);
System.out.println (Jsonarray.fromobject (Pager)). getString (0). toString ());
Return (Jsonarray.fromobject (pager)). getString (0). toString ();
Do not write. getString (0) One more bracket, return is an array, write is to return the first object. Public Bootpage getbypage (String hql,bootpage pager,map<string, object> condition) {if (pager = null) {th Row new IllegalArgumentException ("pagination cannot beis empty! ");}
Query q = sessionfactory.getcurrentsession (). CreateQuery (HQL);
Q.setfirstresult (Pager.getoffset ());
Q.setmaxresults (Pager.getlimit ());
if (condition!= null) {q.setproperties (condition);
} pager.setrows (Q.list ());
Pager.settotal (This.countall (HQL, condition));
return pager;
Protected Long Countall (String hql, map<string, object> condition) {if (hql = null) {return 0l;
String tmphql = Hql.tolowercase ();
String regex = hql.substring (0, Tmphql.indexof ("from"));
HQL = Hql.replacefirst (Regex, select COUNT (*));
Query q = sessionfactory.getcurrentsession (). CreateQuery (HQL);
if (condition!= null) {q.setproperties (condition);
Return (Long) Q.uniqueresult ();
Public final class Bootpage<t> {protected Long;
protected list<t> rows;
protected int limit=0;
protected int offset = 0;
protected String order = "ASC";
If you want to further study, you can click here to learn, and then attach 3 wonderful topics:
Bootstrap Learning Course
Bootstrap Practical Course
Bootstrap Plugin Usage Tutorial
The above is for everyone to share the use of bootstrap table, I hope to master the use of bootstrap table is helpful.