package com.yxq.model;
public class CreatePage {
private int CurrentP; //当前页码
private int AllP;
private int AllR;
private int PerR;
private String PageLink; //分页导航栏信息
private String PageInfo; //分页状态显示信息
public CreatePage(){}
public int getAllP() {
return AllP;
}
/**
* 计算总页数
* @param allP
*/
public void setAllP() {
AllP = (AllR%PerR==0)?(AllR/PerR):(AllR/PerR + 1);
}
public int getAllR() {
return AllR;
}
public String getPageLink() {
return PageLink;
}
public void setPageLink(String gowhich) {
if(gowhich==null)
gowhich="";
if(gowhich.indexOf("?")>=0)
gowhich+="&";
else
gowhich+="?";
if(AllP>1){
PageLink="<table border='0' cellpadding='3'><tr><td>";
if(CurrentP>1){
PageLink+="<a href='"+gowhich+"showpage=1'>首页</a> ";
PageLink+="<a href='"+gowhich+"showpage="+(CurrentP-1)+"'>上一页</a> ";
}
if(CurrentP<AllP){
PageLink+="<a href='"+gowhich+"showpage="+(CurrentP+1)+"'>下一页</a> ";
PageLink+="<a href='"+gowhich+"showpage="+AllP+"'>尾页</a>";
}
PageLink+="</td></tr></table>";
}
}
public String getPageInfo() {
return PageInfo;
}
public void setPageInfo() {
if(AllP>1){
PageInfo="<table border='0' cellpadding='3'><tr><td>";
PageInfo+="每页显示:"+PerR+"/"+AllR+" 条记录!";
PageInfo+="当前页:"+CurrentP+"/"+AllP+" 页!";
PageInfo+="</td></tr></table>";
}
}
public void setAllR(int allR) {
AllR = allR;
}
public int getPerR() {
return PerR;
}
public void setPerR(int perR) {
PerR = perR;
}
public int getCurrentP() {
return CurrentP;
}
public void setCurrentP(String currentP) {
if(currentP==null||currentP.equals(""))
currentP="1";
try{
CurrentP=Integer.parseInt(currentP);
}catch(NumberFormatException e){
CurrentP=1;
e.printStackTrace();
}
if(CurrentP<1)
CurrentP=1;
if(CurrentP>AllP)
CurrentP=AllP;
}
}
分页类
最新推荐文章于 2021-10-01 09:00:20 发布
