分页查询工具类
相信大家在编写java程序的时候,从数据库中获取数据,往往查询数据有时候数据过多需要分页,这里给大家分享一下,话不多说,直接上代码:
package com.util;
import java.util.List;
/**
* 分页工具类
*
* @author system
*
*/
public class pageUtils {
// 总页数
private int count;
// 当前页数
private int index;
// 首页
private int first = 1;
// 尾页
private int last;
// 下一页
private int next;
// 上一页
private int back;
// 每页条数
private int pageSize = 9;
// 数据集合
private List list;
/**
*
* @param rowcount
* 总记录数
* @param index
* 当前页
*/
public pageUtils(int rowcount, int index) {
this.index = index;
if (rowcount % pageSize == 0) {
count = rowcount / pageSize;
} else {
count = rowcount / pageSize + 1;
}
if (index > 1) {
back = index - 1;
} else {
back = 1;
}
if (index < count) {
next = index + 1;
} else {
next = count;
}
last = count;
}
public pageUtils() {
super();
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
public int getFirst() {
return first;
}
public void setFirst(int first) {
this.first = first;
}
public int getLast() {
return last;
}
public void setLast(int last) {
this.last = last;
}
public int getNext() {
return next;
}
public void setNext(int next) {
this.next = next;
}
public int getBack() {
return back;
}
public void setBack(int back) {
this.back = back;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
}

浙公网安备 33010602011771号