📄 pagebean.java
字号:
package page.test.pagebean;
import java.util.List;
public class PageBean {
private List list;// 要返回的每一页的记录列表
private int allRows;
private int pageSize;
private int totalPage;
private int currentPage;
private boolean isFirstPage;
private boolean isLastPage;
private boolean hasPreviousPage;
private boolean hasNextPage;
public List getList() {
return list;
}
public void setList(List list) {
this.list = list;
}
public int getAllRows() {
return allRows;
}
public void setAllRows(int allRows) {
this.allRows = allRows;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public void init() {
this.isFirstPage = isFirstPage();
this.isLastPage = isLastPage();
this.hasNextPage = isHasNextPage();
this.hasPreviousPage = isHasPreviousPage();
}
private boolean isHasPreviousPage() {
// TODO Auto-generated method stub
return currentPage != 1;
}
private boolean isHasNextPage() {
// TODO Auto-generated method stub
return currentPage != totalPage;
}
private boolean isLastPage() {
// TODO Auto-generated method stub
return currentPage == totalPage;
}
private boolean isFirstPage() {
// TODO Auto-generated method stub
return currentPage == 1;
}
// 计算总页数
public static int countTotalPage(final int allRows, final int pageSize) {
int totalPage = (allRows + pageSize - 1) / pageSize;
return totalPage;
}
// 当前页
public static int coutnCurrentPage(int page) {
final int curPage = (page == 0 ? 1 : page);
return curPage;
}
// 当前页的起始
public static int countOffset(final int currentPage, final int pageSize) {
final int offset = (currentPage - 1) * pageSize;
return offset;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -