java web 分页查询、显示

package com.wlzq.entity;

public class Page {

	public int firstRow = 0; 
	public int listRow; 
	public int pageNow;
	private int count;
	private int pageCount;
	private StringBuffer page;
	public String url;
	
	/**
	 * @param listRow 每页显示数
	 * @param pageNow 当前页
	 * @param count 总数
	 * @param url 跳转url
	 */
	public Page(int listRow, int pageNow,int count,String url) {
		this.listRow = listRow;
		this.count = count;
		this.pageNow = pageNow;
		this.pageCount = (int)Math.ceil((double)this.count/this.listRow);
		this.page = new StringBuffer();
		this.firstRow = (this.pageNow - 1)*this.listRow;
		this.url = url;
	}

	public String getUrl(){
		page.append("<div class='inline pull-right page' >");
		page.append("<a href='"+this.url+"&pageNow=1"+"'>首页</a>"+"<a href='"+this.url+"&pageNow="+(pageCount)+"'>末页</a>");
		if(this.pageNow != 1){
			page.append("<a href='"+this.url+"&pageNow="+(this.pageNow-1)+"'>上一页</a>");
		}
		for(int i = 1; i<=this.pageCount;i++){
			if(i == this.pageNow){
				page.append("<span class='current'>"+i+"</span>");
				continue;
			}
			page.append("<a href='"+this.url+"&pageNow="+i+"'>"+i+"</a>");
		}
		if(this.pageNow != this.pageCount){
			page.append("<a href='"+this.url+"&pageNow="+(this.pageNow+1)+"'>下一页</a>");
		}
		page.append("当前 "+this.pageNow+" 页/共 "+this.pageCount+" 页");
		page.append("</div>");
		return page.toString();
	}
	
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值