从数据库中读取的记录怎么样用JAVABEAN分页.编程
2013-12-06
展开全部
package aztx.page;
import java.sql.*;
//javabean分页程序,by 爱在他乡 。欢迎大家转载,指教。
public class PagBean {
private int curpage ;//当前页
private int totalpage ;//总页数
private int perpage = 10 ;//每页显示的条数
private int nextpage ;//下一页
private int prepage ;//上一页
private int startrow ;//开始显示的条数
private int totalrows = 0 ;//总记录条数
public PagBean(){}
public void setTotalpage(int value){
this.totalpage = value ;
}
public void setStartrow(){
}
public void setCurpage(int value){
this.curpage=value;
}
public void setNextpage(){
}
public void setPrepage(){
}
public int getTotalpage(ResultSet rs)throws Exception{
while(rs.next()){
totalrows++ ;
}
if(totalrows%perpage==0)
totalpage = totalrows/perpage ;
else
totalpage = totalrows/perpage + 1;
return totalpage ;
}
public int getStartrow() {
startrow = (curpage-1)*perpage+1;
return startrow ;
}
public int getCurpage(){
return curpage ;
}
public int getNextpage(){
nextpage =curpage +1 ;
return nextpage ;
}
public int getPrepage(){
prepage =curpage - 1 ;
return prepage ;
}
}
import java.sql.*;
//javabean分页程序,by 爱在他乡 。欢迎大家转载,指教。
public class PagBean {
private int curpage ;//当前页
private int totalpage ;//总页数
private int perpage = 10 ;//每页显示的条数
private int nextpage ;//下一页
private int prepage ;//上一页
private int startrow ;//开始显示的条数
private int totalrows = 0 ;//总记录条数
public PagBean(){}
public void setTotalpage(int value){
this.totalpage = value ;
}
public void setStartrow(){
}
public void setCurpage(int value){
this.curpage=value;
}
public void setNextpage(){
}
public void setPrepage(){
}
public int getTotalpage(ResultSet rs)throws Exception{
while(rs.next()){
totalrows++ ;
}
if(totalrows%perpage==0)
totalpage = totalrows/perpage ;
else
totalpage = totalrows/perpage + 1;
return totalpage ;
}
public int getStartrow() {
startrow = (curpage-1)*perpage+1;
return startrow ;
}
public int getCurpage(){
return curpage ;
}
public int getNextpage(){
nextpage =curpage +1 ;
return nextpage ;
}
public int getPrepage(){
prepage =curpage - 1 ;
return prepage ;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询