The effect is as shown! Display up to 10 records;
The full JSP and background code are as follows:
<%@ page contenttype= "Text/html;charset=utf-8"%><%@ taglib prefix= "C" uri= "http://java.sun.com/jsp/jstl/ Core "%><%@ taglib prefix=" FMT "uri=" http://java.sun.com/jsp/jstl/fmt "%><%@ taglib prefix=" tags "tagdir=" /web-inf/tags "%><%@ taglib prefix=" Shiro "uri=" http://shiro.apache.org/tags "%><c:set var=" CTX "value=" $ {PageContext.request.contextPath} "/>
Java Code paging tool class;
Package Cn.enetic.wodm.entity;import java.util.hashmap;import java.util.map;/** * pagination * @author Administrator * */public C Lass Pageutil {private int totalnum;//total number of records; private int totalpage;//total pages private int currpage;//current page number; private int pagenum = 20;//default page record number; private int startnum = 1;//start number; private int endnum;//end number; private int startpage;//Start page; private int endpage;//End page; Public Pageutil () {} public pageutil (int pagenum,string key,object value) {params.put (key, value); This.pagenum = Pagenum; } public pageutil (int pagenum) {this.pagenum = Pagenum; } private map<string, object> params=new hashmap<string, object> ();//Å è¡#̈亞 If 暟 arrival list?? public void settotalpage (int totalnum) {int num = totalnum% Pagenum; if (num = = 0) {totalpage = Totalnum/pagenum; } else {totalpage = totalnum/pagenum + 1; }} public void initpage (int totalnum) {this.totalNum = Totalnum; Settotalpage (totalnum);//OptIn pickaxes marriage?? 闈 ㈡?? StartPage = 1; EndPage = Totalpage; if (currpage<=0) {this.currpage=1; }else if (currpage>=totalpage) {this.currpage=totalpage; } startnum = Pagenum * CURRPAGE-PAGENUM; if (startnum<=0) {startnum=0;} Endnum = Pagenum * currpage; if (Endnum > Totalnum) {endnum = Totalnum; }} public int gettotalnum () {return totalnum; } public void Settotalnum (int totalnum) {this.totalnum = Totalnum; } public int Getcurrpage () {return currpage; } public void Setcurrpage (int pagenumber) {if ("". Equals (PageNumber)) {this.currpage=1; }else{This.currpage=pagenumber; }} public int getpagenum () {return pagenum; } public void Setpagenum (int pagenum) {this.pagenum = Pagenum; } public int Getstartnum () {RETUrn Startnum; } public void Setstartnum (int startnum) {this.startnum = Startnum; } public int Getendnum () {return endnum; } public void Setendnum (int endnum) {this.endnum = Endnum; } public int Getstartpage () {return startpage; } public void Setstartpage (int startpage) {this.startpage = StartPage; } public int Getendpage () {return endpage; } public void Setendpage (int endpage) {this.endpage = EndPage; } public map<string, Object> Getparams () {return params; } public void SetParams (map<string, object> params) {this.params = params; } public int Gettotalpage () {return totalpage; }}
Control layer Code;//If you click on the Query button, the number of pages is emptied
The total number of pages;
int totalnumber=0; if (("". Equals (company) | | Company==null) &&pagesize!=20) {totalnumber=pagesize; Currpage = 1; }else{Totalnumber = This.userCPService.getTotalnumber (company); } pageutil page = new Pageutil (20); Page.setcurrpage (Currpage); Page.initpage (Totalnumber); int startnum = Page.getstartnum (); Get the USERCP of the audit pass and the corresponding click-through number; List<object[]> AllUser = This.userCPService.getAllPassUserCPsAndClicks (startnum , PageSize, company); Model.addattribute ("AllUser", AllUser); Model.addattribute ("page", page); Model.addattribute ("Company" and company); Model.addattribute ("type", type); Model.addattribute ("SortType", SortType); Model.addattribute ("Page_size", "20"); Model.addattribute ("Currpage", currpage); Model.addattribute ("Navigatecolor", Navigatecolor); Model.addattribute ("M", m); return "Rankstatistics/cpranklist"; }
JSP page pagination Display data