分页每显示的页数相加不能保存
public PageBean(){
System.out.println("999999");
}
int curr; //当前页
int count; //总页数
int size; //每页显示数据数
int rows=0; //数据的所有行数
boolean last; // 是否是最后一页
public PageBean(FinghtDao PageDaoFactory) throws SQLException {
System.out.println("000000000");
if (this.rows == 0) {//获取所有的数据条数
System.out.println(PageDaoFactory.findcount()+"..............");
this.rows = PageDaoFactory.findcount();
}
this.curr=getCurr();
this.size = 5;//设定页面显示数据大小
this.count = (int) Math.ceil((double) this.rows / this.size);//获得页数
this.last=isLast();
}
public PageBean(FinghtDao PageDaoFactory,int size) throws SQLException{
if (this.rows == 0) {//获取所有的数据条数
this.rows = PageDaoFactory.findcount();
}
this.curr=getCurr();
this.size = size;//设定页面显示数据大小
this.count = (int) Math.ceil((double) this.rows / this.size);
this.last=isLast();
}
public PageBean(FinghtDao PageDaoFactory,int curr,int size) throws SQLException{
if (this.rows == 0) {//获取所有的数据条数
this.rows =PageDaoFactory.findcount();
}
this.curr=curr;
this.size = size;//设定页面显示数据大小
this.count = (int) Math.ceil((double) this.rows / this.size);
this.last=isLast();
}
public String pageDeal(String pageDo) {
String str = " limit ";
//首页
if (pageDo.equals("first")) {
setCurr(1);
str += "" + getSize();
}
//尾页
if (pageDo.equals("end")) {
setCurr(getCount());
str += "" + ((getCount() - 1) * getSize());
str += "," + (getRows() - (getCount() - 1) * getSize());
}
//下一页
if (pageDo.equals("next")) {
if(getCurr()<getCount()){
str += "" + (getCurr() * getSize());
str += "," + getSize();
setCurr(getCurr() + 1);
getCurr()+1每次加1为什么保存不了,不能累加,以前我是保存在session上的,我这样在jspaction每次调用一次这个方法,它的getCurr()永远不变,没有累加,怎么把它存到一个地方累加
}else{
setCurr(getCount());
str += "" + ((getCount() - 1) * getSize());
str += "," + (getRows() - (getCount() - 1) * getSize());
}
}
//上一页
if (pageDo.equals("prv")) {
setCurr(getCurr() - 1);
str += "" + (getCurr() * getSize() - getSize());
str += "," + getSize();
}
return str;
}
//返回总页数,总页最小也等于1
public int getCount() {
return (count == 0) ? 1 : count;
}
//设置总页数
public void setCount(int count) {
this.count = count;
}
//返回当前页,当前页最小也等于1
public int getCurr() {
return (curr == 0) ? 1 : curr;
}
//设置当前页
public void setCurr(int curr) {
this.curr = curr;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public boolean isLast() {
return (curr==count)?true:false;
}
public void setLast(boolean last) {
this.last = last;
}
getCurr()+1每次加1为什么保存不了,不能累加,以前我是保存在session上的,我这样在jspaction每次调用一次这个方法,它的getCurr()永远不变,没有累加,怎么把它存到一个地方累加