分页每显示的页数相加不能保存

quanlei1507053 2011-05-12 11:41:20
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()永远不变,没有累加,怎么把它存到一个地方累加
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
安特矮油 2011-05-12
  • 打赏
  • 举报
回复
你的这个bean是这么获得的?这个很重要

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧