Prodigy/kf智
我的博客
posts - 20,comments - 7,trackbacks - 0
在struts-config.xml里配置 PageBean这个类是进行分页的: package com.xiaozhi.pagebean; public class PageBean { //设置当前页数 private int currentPage = 0 ; //一共有多少条数据 private int countdata = 0 ; //1页里应该有多少数据 private int everypage = 0 ; public int getCurrentPage() { if(countdata <= 0) { return 0 ; } return this.currentPage; } //设置当前页的并进行判断 public void setCurrentPage(int currentPage) { int countpage = 0 ; countpage = this.getCountPage() ; if(currentPage < 0) { this.currentPage = 0 ; return ; } else if(currentPage >= countpage) { this.currentPage = countpage-1 ; return ; } this.currentPage = currentPage; } public int getCountdata() { return countdata; } public void setCountdata(int countdata) { this.countdata = countdata; } public int getEverypage() { return everypage; } public void setEverypage(int everypage) { this.everypage = everypage; } //得到一共有多少页 public int getCountPage() { if(countdata%everypage == 0) { return countdata/everypage ; } else { return countdata/everypage+1 ; } } //得到起始页的数据(是当前页的开始数据) public int getBeginData() { // System.out.println("*****@@@@"+this.currentPage+"*********") ; // // System.out.println("*****"+this.currentPage * this.countdata+"*********") ; return this.currentPage * this.everypage ; } //得到结尾的数据(是当前页的最后的数据) public int getEndData() { // System.out.println("%%%%%%%%%%"+((this.currentPage+1)*this.everypage-1)+"%%%%%%%%%%%%%%") ; return (this.currentPage+1)*this.everypage-1 ; } }
posted on 2006-04-17 11:07 xiaozhi 阅读(305) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: