数据库代码分页显示entity

数据库代码分页显示entity

  1. PageBean—用于存放jsp界面需要的内容代码`package entity;

import java.util.List;

public class PageBean {

 private List lists;//记住页面数据
    private int totalrecord;//总记录数
    private int pagesize;//每页多少条  通过queryinfo-pagesize
    
    private int totalpage;//总共多少页  计算
    
    private int currentpage;//当前第几页
    private int previouspage;//上一页
    private int nextpage;//下一页
    
    private int[] pagebar;//页码条--根据总页数生成页码条
    
    
     
   //计算总页数
  	public int getTotalpage() {
  		//100 5 20
  		//101 5 21
  		
  		if(this.totalrecord%this.pagesize ==0){
  			this.totalpage=this.totalrecord/this.pagesize;
  		}
  		this.totalpage=this.totalrecord/this.pagesize+1;
  		return totalpage;
  	}
  	
	public List getLists() {
		return lists;
	}
	public void setLists(List lists) {
		this.lists = lists;
	}
	public int getTotalrecord() {
		return totalrecord;
	}
	public void setTotalrecord(int totalrecord) {
		this.totalrecord = totalrecord;
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	
	
	
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}
	
	
	//计算previouspage和nextpage
	public int getPreviouspage() {
		
		if(this.currentpage-1<1) {//没有上一页
			this.previouspage=1;
		}
		else {
			this.previouspage=this.currentpage-1;
		}
		
		return previouspage;
	}

	public int getNextpage() {
		
		if(this.currentpage+1>=this.totalpage) {
			this.nextpage=this.totalpage;
		}
		else {
			this.nextpage=this.currentpage+1;
		}
		return nextpage;
	}
	
	public int[] getPagebar() {
		
		int[] pagebar=new int[this.totalpage]; //定义一个新的pagebar大小为页面总数
		
		for(int i=1;i<=this.totalpage;i++) {
			pagebar[i-1]=i;
		}
			
			
		this.pagebar=pagebar;	
		return pagebar;
	}

}
`
2. QueryInfo–用于存放用户发送的读取页面请求

package entity;

public class QueryInfo {
	
	private int currentpage=1;  //用户当前页
	private int pagesize=20;//记住用户想看的页面大小  默认值
	
	private int startindex;//记住用户看的页在数据库的起始位置,算出来的不需要set方法

	
	public QueryInfo(){
		super();
	}
	public QueryInfo(int currentpage,int pagesize){
		super();
		this.currentpage = currentpage;
		this.pagesize = pagesize;
		this.startindex=(this.currentpage-1)*this.pagesize;
		
	}

	public int getCurrentpage() {
		return currentpage;
	}

	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}

	public int getPagesize() {
		return pagesize;
	}

	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}

	public int getStartindex() {
		//算起始位置
		this.startindex=(this.currentpage-1)*this.pagesize;
		return startindex;
	}

	
	
	

}

3.QueryResult—用于存放一页数据内容`package entity;

import java.util.List;

public class QueryResult {

private List<Login_record> list;  //记住用户看的数据
private int totalrecord;//记住总记录数


public QueryResult() {
	super();
	this.list = null;
	this.totalrecord =0;
}

public QueryResult(List<Login_record> list, int totalrecord) {
	super();
	this.list = list;
	this.totalrecord = totalrecord;
}
public List getList() {
	return list;
}
public void setList(List<Login_record> list) {
	this.list = list;
}
public int getTotalrecord() {
	return totalrecord;
}
public void setTotalrecord(int totalrecord) {
	this.totalrecord = totalrecord;
}

}
`

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值