str.append("/style");
str.append("div class=\"meneame\"");
// 判定是否有上一页
if (this.currentpage1) {
str.append("a href='" + url
+ "currentpage=1' hidefocus=\"true\"首页/a");
str.append("");
str.append("a href='" + url + "currentpage=" + ProPage
+ "' hidefocus=\"true\"上一页/a");
str.append("");
} else {
str.append("span class=\"disabled\"首页/span");
str.append("");
str.append("span class=\"disabled\"上一页/span");
str.append("");
}
// 显示中间的图片
if (this.pagecount = 10) {
for (int i = 1; i = this.pagecount; i++) {
if (this.currentpage == i) {
str.append("span class=\"current\"" + i + "/span");
} else {
str.append("a href='" + url + "currentpage=" + i
+ "' hidefocus=\"true\"" + i
+ "/a");
}
}
} else {
// 说明总数有超过10页
// 制定特环的开始页和结束页
int endPage = this.currentpage + 4;
if (endPagethis.pagecount) {
endPage = this.pagecount;
}
int startPage = 0;
if (this.pagecount = 8this.currentpage = 8) {
startPage = this.currentpage - 5;
} else {
// 表示从第一页开始算
startPage = 1;
}
System.out.println(startPage);
System.out.println(endPage);
for (int i = startPage; i = endPage; i++) {
if (this.currentpage == i) {
str.append("span class=\"current\"" + i + "/span");
} else {
str.append("a href='" + url + "currentpage=" + i
+ "' hidefocus=\"true\"" + i
+ "/a");
}
}
}
// 判断下一页和尾页
if (this.currentpagethis.pagecount) {
if (this.currentpagethis.pagecount - 10) {
str.append("...");
str.append("a href='" + url + "currentpage="
+ (this.pagecount - 1) + "' hidefocus=\"true\""
+ (this.pagecount - 1) + "/a");
str.append("a href='" + url + "currentpage="
+ this.pagecount + "' hidefocus=\"true\""
+ this.pagecount + "/a");
}
str.append("a href='" + url + "currentpage=" + Nextpage
+ "' hidefocus=\"true\"下一页/a");
str.append("");
} else {
str.append("span class=\"disabled\"下一页/span");
str.append("");
}
if (this.pagecount1this.currentpage != this.pagecount) {
str.append("a href='" + url + "currentpage=" + pagecount
+ "' hidefocus=\"true\"尾页/a");
str.append("");
} else {
str.append("span class=\"disabled\"尾页/span");
str.append("");
}
str.append("/div");
}
return str.toString();
}
public String getParamUrl() {
String url = "";
url = this.request.getRequestURI().toString();
if (url.indexOf("?") == -1) {
url = url + "?";
}
String totalParams = "";
Enumeration params = this.request.getParameterNames();// 得到所有参数名
while (params.hasMoreElements()) {
String tempName = params.nextElement().toString();
String tempValue = https://www.04ip.com/post/this.request.getParameter(tempName);
if (tempValue != null!tempValue.equals("")
!tempName.equals("currentpage")) {
if (totalParams.equals("")) {
totalParams = totalParams + tempName + "=" + tempValue;
} else {
totalParams = totalParams + "" + tempName + "="
+ tempValue;
}
}
}
String totalUrl = url + totalParams;
return totalUrl;
}
}
如何用java实现分页效果(eclipse工具)package dl.wsxx.base;
public class Pager {
private int totalRows; // 总行数
private int pageSize; // 每页显示的行数
private int currentPage; // 当前页号
private int totalPages; // 总页数
private int startRow; // 当前页在数据库中的起始行
private int pageStartRow; // 当前页开始行
private int pageEndRow; // 当前页结束行
推荐阅读
- 小学体育新颖游戏策划教案,小学体育游戏设计
- 我怎么感觉Python比c难,python比c简单吗
- html5定义,html5定义滑块控件颜色
- reshade安装出现net,安装net报错
- Linux命令连接串口 linux怎么连接串口
- 北欧蓝电视背景搭什么窗帘,北欧蓝墙面配什么颜色窗帘
- cpu烧穿了会发生什么,cpu烧了会发热吗
- 女装直播带货流程话术技巧,女装直播带货怎么做
- php数据推送 php 推送