}
out.print("[");
//打印需要显示的页码
for(int c=CounterStart;c=CounterEnd;c++){
if(c MaxPage){
if(c == PageNo){
if(c %PageSize == 0){
out.print(c);
}else{
out.print(c+" ,");
}
}else if(c % PageSize == 0){
out.print("a href=https://www.04ip.com/post/TestPage.jsp?PageNo="+c+""+c+"/a");
}else{
out.print("a href=https://www.04ip.com/post/TestPage.jsp?PageNo="+c+""+c+"/a ,");
}
}else{
if(PageNo == MaxPage){
out.print(c);
break;
}else{
out.print("a href=https://www.04ip.com/post/TestPage.jsp?PageNo="+c+""+c+"/a");
break;
}
}
}
out.print("]");;
if(PageNoMaxPage){ //如果当前页不是最后一页,则显示下一页链接
NextPage = PageNo + 1;
out.print("a href=https://www.04ip.com/post/TestPage.jsp?PageNo="+NextPage+"下一页/a");
}
//同时如果当前页不是最后一页,要显示最后一页的链接
if(PageNoMaxPage){
LastRec = RecordCount % PageSize;
if(LastRec == 0){
LastStartRecord = RecordCount - PageSize;
}
else{
LastStartRecord = RecordCount - LastRec;
}
out.print(":");
out.print("a href=https://www.04ip.com/post/TestPage.jsp?PageNo="+MaxPage+"最后一页/a");
}
out.print("/font");
%
/div
/td
/tr
/table
%
rs.close();
statement.close();
connection.close();
%
/body
/html
求java分页代码,急用!package common.util;
import java.util.*;
public class PageController implements IPageModel {
private Collection model;
//数据总行数
private int totalRowCount = 0; //
//总页数
private int pageCount = 0;
//每页应显示的行数
private int maxPageRowCount = 0;
//当前页行数
private int currPageRowCount = 0;
//当前页号
private int currPageNum;
//默认构造
public PageController() {
super();
}
//传入模型
public PageController(Collection model) {
setPageController(model);
}
//设一个分页模型
public void setPageController(Collection model) {
this.model = model;
this.totalRowCount = model.size();
}
/**
* 总页数
* @return int
*/
public int getPageCount() {
return this.pageCount;
}
/**
* getPageContents
*
* @param intPageNum int
* @return Object
*/
public Object getPageContents(int intPageNum) {
//非法数据
if(intPageNum1){
intPageNum=1;
}
if(intPageNumpageCount){
intPageNum=pageCount;
}
//指定当前页
this.currPageNum=intPageNum;
int i = 0;
ArrayList arr = new ArrayList();
//如果是合法的范围
if (intPageNum0intPageNum = pageCount) {
//计算该页的开始号和结束号
int lfromrow = (intPageNum - 1) * maxPageRowCount;
arr = (ArrayList) getElementsAt(model, lfromrow, lfromrow + maxPageRowCount-1);
}
currPageNum=intPageNum;
return arr;
}
public Object getLastPage() {
return this.getPageContents(pageCount);
}
public Object getFirstPage() {
return this.getPageContents(0);
}
/**
* getCurrentPageRowsCount
*
* @return int
*/
public int getCurrentPageRowsCount() {
if(currPageNumpageCount){
return maxPageRowCount;
}
else{//最后一页
return totalRowCount-(pageCount-1)*maxPageRowCount;
}
}
public int getCurrentPageNum(){
return currPageNum;
}
/**
* setMaxPageRows
*
* @return int
*/
public void setMaxPageRows(int rowCount) {
maxPageRowCount = rowCount;
//计算总页数
推荐阅读
- js获取文本域的值,js获取文本域的内容
- 新媒体创业如何盈利,新媒体创业盈利模式有哪些?
- 恐怖游戏冒险解谜攻略视频,恐怖冒险解谜游戏大全
- 抖音游戏直播声音关闭了,抖音游戏直播怎么关闭声音
- python看函数参数 python函数参数类型检查
- Python字符串中剔除汉字,python字符串去掉汉字
- css取消文本居中,css取消字体样式
- vb.net控件数据绑定 vb60中的数据绑定控件必须
- jquery写无缝轮播,jquery图片轮播无缝连接