调用方法:
int pageNo=ps.getFenyePageNo3(param,lastPage);
方法代码:
private int currentPageNo3=1;
public int getFenyePageNo3(String param, int lastPage) {
if ("first".equals(param) || null == param) {
currentPageNo3 = 1;
}
else if ("next".equals(param)) {
if (currentPageNo3 < lastPage) {
System.out.println("当前页3::"+currentPageNo3);
currentPageNo3++;
}
}
else if ("previous".equals(param)) {
if (currentPageNo3 > 1) {
currentPageNo3--;
}
}
else if ("last".equals(param)) {
currentPageNo3 = lastPage;
}
return currentPageNo3;
}
没错这是个分页::
出现的错误情况::
假如第一次调用这个方法时,我点击翻页,在第20页时停止了,当第二次调用这个方法时,在点击翻页,会出现第21页,而不是第二页。
我想实现,每调用完一次这个getFenyePageNo3()方法,就将保存在currentPageNo3里面的值清空,当再次调用这个方法的时候,不会出现currentPageNo3还保存着上一次调用保存的页数。
这样描述还清楚吗
It depends on how you
int pageNo=ps.getFenyePageNo3(param,lastPage);
ps this object. If it is a singleton, it will definitely be recorded. If it is new every time, it will definitely not be recorded. Or you assigned currentPageNo3 when passing it in from the front end.You just need to change the local variables of the
currentPageNo3
声明为getFenyePageNo3
methodIs your idea of paging wrong? Wouldn’t it be better to accept two parameters (pageNo, pageSize) directly? Why should we save which page in paging?
If it is java web, the client and server are not tightly tied to each other like this.