When learning to use bootstrap tables, when paginating the client, with the help of friends, I found the document http://bootstrap-table.wenzhixin.net.cn/examples/
The number of pages per page that are passed to the background is found, and the number of record starts Offset.
Start encapsulating, share my code, get the page number and page number from the bootstrap table, and hand it over to the background for processing.
$('#table').bootstrapTable({ url: '<%=path%>/FeedList.cqzk', striped: true, pagination: true, pageList: [3,5,20], pageSize:3, pageNumber:1, sidePagination:'server',//Set as server-side pagination columns: [{ field: 'title', 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(); // If you don't write .getString(0), you will have an extra bracket, and the returned array is the one, and if you write it, you will return the first object. } public BootPage getByPage(String hql,BootPage pager,Map<String, Object> condition){ if (pager == null) { throw new IllegalArgumentException("Page cannot be 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 total; protected List<T> rows; protected int limit=0; protected int offset = 0; protected String order ="asc" ;If you still want to study in depth, you can click here to study and attach 3 exciting topics to you:
Bootstrap learning tutorial
Bootstrap practical tutorial
Bootstrap plug-in usage tutorial
The above is the usage method of Bootstrap Table shared with you. I hope it will be helpful for you to master the usage method of Bootstrap Table.