📄 page.java
字号:
/*
* Created on 2006-5-15
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.bookstore.db;
/**
* Title:<br>
* Description:
* Copyright: Copyright (c)<br>
* @author zhanghong
* @version 1.0
*/
public class Page implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 2770164670991175678L;
public int recordCounterPerPage = 0; //每页的记录数
public int recordTotalCount = 0;//总记录数
public int currentPageno; //当前页号
public int totalPageCount; //总页数
public int loopCounter = 0;//循环时用
//public int startRecordNo = 1;//开始时的记录号
public Page(int recordCounterPerPage,
int recordTotalCount,
int currentPageno,
//int totalPageCount,
int loopCounter){
init(recordCounterPerPage,recordTotalCount,currentPageno,
loopCounter);
}
/**
* @param recordCounterPerPage
* @param recordTotalCount
* @param currentPageno
* @param totalPageCount
* @param loopCounter
* @param startRecordNo
*/
protected void init(int recordCounterPerPage,
int recordTotalCount,
int currentPageno,
//int totalPageCount,
int loopCounter){
this.recordCounterPerPage = recordCounterPerPage;
this.recordTotalCount = recordTotalCount;
this.currentPageno = currentPageno;
//this.totalPageCount = totalPageCount;
this.loopCounter = loopCounter;
//this.startRecordNo = startRecordNo;
if(recordTotalCount%recordCounterPerPage==0)
{
totalPageCount = recordTotalCount/recordCounterPerPage;
}
else
{
totalPageCount = recordTotalCount/recordCounterPerPage + 1;
}
if(currentPageno<=1)
{
currentPageno = 1;
}
if(currentPageno >= totalPageCount)
{
currentPageno = totalPageCount;
}
}
/**
* 取当前页码
* @return 当前页码
*/
public int getCurrentPageNo(){
return this.currentPageno;
}
//取得总页数
public int getTotalPageCount(){
return this.totalPageCount;
}
/**
* @param jspName JSP文件的名称
* @return String
*/
public String getHTML(String jspName){
StringBuffer html= new StringBuffer(256);
html.append("<br><center>");
html.append("<a href='"+jspName+"?currentShowPage=1'>首页</a> ");
if(currentPageno == 1)
{
html.append("<a href='"+jspName+"?currentShowPage="+(currentPageno+1)+"'>下一页</a>");
html.append(" ");
}
if(currentPageno != 1 && currentPageno != totalPageCount && currentPageno != 0)
{
html.append("<a href='"+jspName+"?currentShowPage="+(currentPageno-1)+"'>上一页</a>");
html.append(" ");
html.append("<a href='"+jspName+"?currentShowPage="+(currentPageno+1)+"'>下一页</a>");
html.append(" ");
}
if(currentPageno == totalPageCount && currentPageno != 1)
{
html.append("<a href='"+jspName+"?currentShowPage="+(currentPageno-1)+"'>上一页</a>");
html.append(" ");
}
html.append("<a href='"+jspName+"?currentShowPage="+totalPageCount+"'>最后一页</a>");
html.append(" ");
for(loopCounter=1;loopCounter<=totalPageCount;loopCounter++)
{
if(loopCounter!=currentPageno)
{
html.append("<a href='"+jspName+"?currentShowPage="+loopCounter+"'>"+loopCounter+"</a>");
html.append(" ");
}
else
{
html.append(loopCounter+" ");
}
}
return html.toString();
}
/**
* @param jspName JSP文件的名称
* @return String
*/
public String getIframListHTML(String jspName){
StringBuffer html= new StringBuffer(256);
html.append("<br><center>");
html.append("<a href='"+jspName+"¤tShowPage=1'>首页</a> ");
if(currentPageno == 1)
{
html.append("<a href='"+jspName+"¤tShowPage="+(currentPageno+1)+"'>下一页</a>");
html.append(" ");
}
if(currentPageno != 1 && currentPageno != totalPageCount && currentPageno != 0)
{
html.append("<a href='"+jspName+"¤tShowPage="+(currentPageno-1)+"'>上一页</a>");
html.append(" ");
html.append("<a href='"+jspName+"¤tShowPage="+(currentPageno+1)+"'>下一页</a>");
html.append(" ");
}
if(currentPageno == totalPageCount && currentPageno != 1)
{
html.append("<a href='"+jspName+"¤tShowPage="+(currentPageno-1)+"'>上一页</a>");
html.append(" ");
}
html.append("<a href='"+jspName+"¤tShowPage="+totalPageCount+"'>最后一页</a>");
html.append(" ");
for(loopCounter=1;loopCounter<=totalPageCount;loopCounter++)
{
if(loopCounter!=currentPageno)
{
html.append("<a href='"+jspName+"¤tShowPage="+loopCounter+"'>"+loopCounter+"</a>");
html.append(" ");
}
else
{
html.append(loopCounter+" ");
}
}
return html.toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -