java分页代码思想_javaweb分页思想

var sbPageString ="";

var displayNum = 10;//显示页面数量

var totalPages = ${pageCount}; //页面码数

var pageNumber = ${pagedVo.paging.pageNumber}; //当前页码

var startPage = 0; //首页

var endPage = 0; //最后页

if (totalPages <= displayNum) {

startPage = 1;

endPage = totalPages;

}/* else if (pageNumber <= (displayNum - 1) / 2) {

startPage = 1;

endPage = displayNum;

} else if (pageNumber >= totalPages - (displayNum - 1) / 2) {

startPage = totalPages - displayNum + 1;

endPage = totalPages;

} else {

startPage = pageNumber - (displayNum - 1) / 2;

endPage = pageNumber + (displayNum - 1) / 2;

} */

if(totalPages<=10){

if(totalPages==1||totalPages==0){

sbPageString = "" + 1 + "";

}else{

sbPageString += "上一页 ";

for(var i=1;i<=totalPages;i++){

if(i

sbPageString += "" + i + "";

}else if(i==pageNumber){

sbPageString += "" + pageNumber + "";

}else if(i>pageNumber){

sbPageString += "" + i + "";

}

}

sbPageString += "下一页 ";

}

}

if(totalPages>10){

if(pageNumber!=1){

sbPageString += "上一页 ";

}

if(pageNumber<=4){

for(var i=1;i<=parseInt(pageNumber);i++){

if(i!=pageNumber){

sbPageString += "" + i + "";}

if(i==pageNumber){

sbPageString += "" + pageNumber + "";

}

}

sbPageString += "" + (pageNumber+1) + "";

sbPageString += "" + (pageNumber+2) + "...";

sbPageString += "" + totalPages + "";

}

if(pageNumber>4&&pageNumber<=totalPages-3){

sbPageString += "" + 1 + "...";

sbPageString += "" + (pageNumber-2) + "";

sbPageString += "" + (pageNumber-1) + "";

sbPageString += "" + pageNumber + "";

sbPageString += "" + (pageNumber+1) + "";

sbPageString += "" + (pageNumber+2) + "...";

sbPageString += "" + totalPages + "";

}

if(pageNumber>totalPages-3){

sbPageString += "" + 1 + "...";

sbPageString += "" + (pageNumber-2) + "";

sbPageString += "" + (pageNumber-1) + "";

sbPageString += "" + pageNumber + "";

for(var i=pageNumber+1;i<=totalPages;i++){

sbPageString += "" + i + "";

}

}

if(parseInt(pageNumber)!=totalPages){

sbPageString += "下一页 ";

}

}

$(".yema").append(sbPageString);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值