java分页导航条代码 java分页实现原理( 五 )


str
.append("DIV.meneame SPAN.disabled {BORDER-RIGHT: #ffe3c6 1px solid; PADDING-RIGHT: 7px; BORDER-TOP: #ffe3c6 1px solid; PADDING-LEFT: 7px; PADDING-BOTTOM: 5px; BORDER-LEFT: #ffe3c6 1px solid; COLOR: #ffe3c6; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ffe3c6 1px solid}");
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分页代码,急用!package common.util;
import java.util.*;
public class PageController implements IPageModel {

推荐阅读