欢迎来到天天文库
浏览记录
ID:34902788
大小:266.50 KB
页数:85页
时间:2019-03-13
《java分页使用多种方法实现分页实用技术》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、个人收集整理仅供参考学习////在struts中分页地一种实现//////////我地项目中地分页功能1,思路使用一个页面控制类,它记录页面信息,如上页,下页,当前页等.在查询地Action中,将这个控制类和查询条件一起传递给数据库访问bean,然后将这两个参数保存在用户session中.在分页控制Action中,利用接收到地分页参数调用数据库访问地bean.b5E2RGbCAP2,实现(1)分页控制类/*@authornick*Createdon2004-3-18*filename:PageController.java***/packagecom.tower.util;
2、/***@authornick*2004-3-18*用来进行翻页控制**/publicclassPageController{inttotalRowsAmount;//总行数booleanrowsAmountSet;//是否设置过totalRowsAmountintpageSize=2;//每页行数intcurrentPage=1;//当前页码intnextPage;intpreviousPage;inttotalPages;//总页数booleanhasNext;//是否有下一页booleanhasPrevious;//是否有前一页Stringdescription;in
3、tpageStartRow;intpageEndRow;publicPageController(inttotalRows){setTotalRowsAmount(totalRows);}85/85个人收集整理仅供参考学习publicPageController(){}/***@parami*设定总行数*/publicvoidsetTotalRowsAmount(inti){if(!this.rowsAmountSet){totalRowsAmount=i;totalPages=totalRowsAmount/pageSize+1;setCurrentPage(1);thi
4、s.rowsAmountSet=true;}}/***@parami**当前页**/publicvoidsetCurrentPage(inti){currentPage=i;nextPage=currentPage+1;previousPage=currentPage-1;//计算当前页开始行和结束行if(currentPage*pageSize5、t;pageStartRow=pageSize*(totalPages-1)+1;}//是否存在前页和后页if(nextPage>totalPages){85/85个人收集整理仅供参考学习hasNext=false;}else{hasNext=true;}if(previousPage==0){hasPrevious=false;}else{hasPrevious=true;};System.out.println(this.description());}/***@return*/publicintgetCurrentPage(){returncurrentPage;}/6、***@return*/publicbooleanisHasNext(){returnhasNext;}/***@return*/publicbooleanisHasPrevious(){returnhasPrevious;}/***@return*/publicintgetNextPage(){returnnextPage;}/***@return*/publicintgetPageSize(){85/85个人收集整理仅供参考学习returnpageSize;}/***@return*/publicintgetPreviousPage(){returnpreviousPa7、ge;}/***@return*/publicintgetTotalPages(){returntotalPages;}/***@return*/publicintgetTotalRowsAmount(){returntotalRowsAmount;}/***@paramb*/publicvoidsetHasNext(booleanb){hasNext=b;}/***@paramb*/publicvoidsetHasPrevious(booleanb){hasPrevious=b;}/***@parami*/pub
5、t;pageStartRow=pageSize*(totalPages-1)+1;}//是否存在前页和后页if(nextPage>totalPages){85/85个人收集整理仅供参考学习hasNext=false;}else{hasNext=true;}if(previousPage==0){hasPrevious=false;}else{hasPrevious=true;};System.out.println(this.description());}/***@return*/publicintgetCurrentPage(){returncurrentPage;}/
6、***@return*/publicbooleanisHasNext(){returnhasNext;}/***@return*/publicbooleanisHasPrevious(){returnhasPrevious;}/***@return*/publicintgetNextPage(){returnnextPage;}/***@return*/publicintgetPageSize(){85/85个人收集整理仅供参考学习returnpageSize;}/***@return*/publicintgetPreviousPage(){returnpreviousPa
7、ge;}/***@return*/publicintgetTotalPages(){returntotalPages;}/***@return*/publicintgetTotalRowsAmount(){returntotalRowsAmount;}/***@paramb*/publicvoidsetHasNext(booleanb){hasNext=b;}/***@paramb*/publicvoidsetHasPrevious(booleanb){hasPrevious=b;}/***@parami*/pub
此文档下载收益归作者所有