WEB开发网
开发学院软件开发Java 分页标签 阅读

分页标签

 2009-09-26 00:00:00 来源:WEB开发网   
核心提示: 4.页面应用<%@taglibprefix="tangs"uri="/WEB-INF/pagination.tld"%><tangs:pagespageNo="pageNo"total="total"

4.页面应用

<%@ taglib prefix="tangs" uri="/WEB-INF/pagination.tld"%>
<tangs:pages pageNo="pageNo" total="total"   theme="text"/>

5.action代码片段

 private Integer total;   
  private Integer pageNo=1;
 public String listAllHotNews(){
 pageConfig.setAllRecordNum(dao.recordCount());
  total = pageConfig.getAllPageNum();
  int start = pageConfig.getPerRecordNum()* (pageNo - 1);
  int size = pageConfig.getPerRecordNum();
  hotNewsList = dao.listAllNews(start,size);
  return SUCCESS;
 }

6.pageConfig.java

 1package cn.com.sunrise.home.credit.page;
 2
 3import cn.com.sunrise.home.util.Constraint;
 4
 5public class PageConfig {
 6    private int allRecordNum;// 总记录数
 7
 8    private int allPageNum;// 总页数
 9
10    private int perRecordNum =Constraint.PAGESIZE;// 每页显示数
11
12    private int currPageNO;// 当前页号
13
14    // 分页提供存取方法
15    public int getAllRecordNum() {
16        return allRecordNum;
17    }
18    //得到总页数,用下面的算法
19    public void setAllRecordNum(int allRecordNum) {
20        this.allRecordNum = allRecordNum;
21        if(allRecordNum % perRecordNum == 0){
22            this.allPageNum = allRecordNum / perRecordNum;
23        }else{
24            this.allPageNum = allRecordNum / perRecordNum + 1;
25        }
26    }
27
28    public int getAllPageNum() {
29        return allPageNum;
30    }
31
32    public void setAllPageNum(int allPageNum) {
33        this.allPageNum = allPageNum;
34    }
35
36    public int getPerRecordNum() {
37        return perRecordNum;
38    }
39
40    public void setPerRecordNum(int perRecordNum) {
41        this.perRecordNum = perRecordNum;
42    }
43
44    public int getCurrPageNO() {
45        return currPageNO;
46    }
47
48    public void setCurrPageNO(int currPageNO) {
49        this.currPageNO = currPageNO;
50    }
51}
52
53

上一页  1 2 3 4 

Tags:标签

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接