JSP页面分页显示数据
2021-07-09 00:07
阅读:365
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:gdi model sof add max sdn round 大于 查询
效果如上图所示!最多显示10条;
完整jsp和后台代码如下:
名次序号 cp名称 总点击量 总付费量(/元) 总收藏量 ${(currPage-1)*20+status.index+1} ${userCP[1]} ${userCP[2]}
- ${i}
- ${i}
- >
- >
- >>
- >>
//java代码分页工具类;
package cn.enetic.wodm.entity; import java.util.HashMap; import java.util.Map; /** * 分页 * @author Administrator * */ public class PageUtil { private int totalNum;// 总记录数; private int totalPage;// 总页数 private int currPage;// 当前页码; private int pageNum = 20;// 默认页面记录数; private int startNum = 1;// 开始数; private int endNum;// 结束数目; private int startPage;// 开始页; private int endPage;// 结束页; 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 Mapparams=new HashMap ();// 鍙傛暟鍒楄?? 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);// 璁剧疆鎬婚??闈㈡?? startPage = 1; endPage = totalPage; if(currPage=totalPage){ this.currPage=totalPage; } startNum = pageNum * currPage - pageNum ; if(startNum 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 getParams() { return params; } public void setParams(Map params) { this.params = params; } public int getTotalPage() { return totalPage; } }
//control层代码; //如果点击了查询按钮,页数清空
// 分页总数;
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(); // 获取审核通过的usercp和对应的点击浏览数; List
JSP页面分页显示数据
标签:gdi model sof add max sdn round 大于 查询
原文地址:http://www.cnblogs.com/SimonHu1993/p/7094563.html
评论
亲,登录后才可以留言!