java pagination_java怎么实现分页

package com.mrjava.dvpms.commons;

import java.util.List;

/**

* 分页表

* @author 李易烜-修改

* 2009-6-17

*/

public class PaginationTable {

private List> entryList;//> 数据

private int totalNumOfRows;// 总行数

private int rowsPerPage = 10;// 每页行数

private int beginIndex = 0;//---> 当前页起始行

private int endIndex;//-----> 终止页

private int pageIndex;//----> 当前页

private int pageCount;//----> 总页数

/** 分页计算-重载1() */

public PaginationTable(){ }

/** 分页计算-重载2(总行数, 终止页) */

public PaginationTable(int totalNumOfRows, int pageIndex) {

//super();

if(pageIndex<=0){

pageIndex=1;

}

this.totalNumOfRows = totalNumOfRows;

if(totalNumOfRows%rowsPerPage==0){

this.pageCount = this.totalNumOfRows/rowsPerPage;

}else {

this.pageCount = this.totalNumOfRows/rowsPerPage+1;

}

if(pageIndex > pageCount){

pageIndex = pageCount;

}

this.pageIndex = pageIndex;

if(totalNumOfRows > 0){

this.beginIndex = (pageIndex-1)*rowsPerPage;

}

this.endIndex = pageIndex*rowsPerPage;

endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;

}

/** 分页计算-重载3(每页行数, 总行数, 终止页) */

public PaginationTable(int rowsPerPage, int totalNumOfRows, int pageIndex) {

//super();

this.rowsPerPage = rowsPerPage;

if(pageIndex<=0){

pageIndex=1;

}

this.totalNumOfRows = totalNumOfRows;

if(totalNumOfRows%rowsPerPage==0){

this.pageCount = this.totalNumOfRows/rowsPerPage;

}else {

this.pageCount = this.totalNumOfRows/rowsPerPage+1;

}

if(pageIndex > pageCount){

pageIndex = pageCount;

}

this.pageIndex = pageIndex;

if(totalNumOfRows > 0){

this.beginIndex = (pageIndex-1)*rowsPerPage;

}

this.endIndex = pageIndex*rowsPerPage;

endIndex = endIndex>this.totalNumOfRows ? this.totalNumOfRows : endIndex;

}

/** 总页数,最少一页,0行也按一页计算 */

public int getTotalNumOfPage() {

return this.totalNumOfRows / this.rowsPerPage + 1;

}

/** 数据 */

public List> getEntryList() {

return entryList;

}

public void setEntryList(List> entryList) {

this.entryList = entryList;

}

/** 总行数 */

public int getTotalNumOfRows() {

return totalNumOfRows;

}

public void setTotalNumOfRows(int totalNumOfRows) {

this.totalNumOfRows = totalNumOfRows;

}

/** 每页行数 */

public int getRowsPerPage() {

return rowsPerPage;

}

public void setRowsPerPage(int rowsPerPage) {

this.rowsPerPage = rowsPerPage;

}

/** 当前页起始行 */

public int getBeginIndex() {

return beginIndex;

}

public void setBeginIndex(int beginIndex) {

this.beginIndex = beginIndex;

}

/** 终止页 */

public int getEndIndex() {

return endIndex;

}

public void setEndIndex(int endIndex) {

this.endIndex = endIndex;

}

/** 当前页 */

public int getPageIndex() {

return pageIndex;

}

public void setPageIndex(int pageIndex) {

this.pageIndex = pageIndex;

}

/** 总页数 */

public int getPageCount() {

return pageCount;

}

public void setPageCount(int pageCount) {

this.pageCount = pageCount;

}

}

2.Action调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值