java分页代码和效果 java分页显示( 三 )


str.append("tr");
str.append("td width='3%' /td");
str.append("td height='26'");
str.append("记录" + this.rscount + "条");
str.append("共" + this.pagecount + "页");
str.append("每页" + this.pagesize + "记录");
str.append("现在" + this.currentpage + "/" + this.pagecount + "页");
str.append("/tdtd");
// 设定是否有首页的链接
if (this.currentpage1) {
str.append("a href='" + url + "currentpage=1'首页/a");
str.append("");
}
// 设定是否有上一页的链接
if (this.currentpage1) {
str.append("a href='" + url + "currentpage=" + ProPage
+ "'上一页/a");
str.append("");
}
// 如果总页数只有10的话
if (this.pagecount = 10) {
for (int i = 1; i = this.pagecount; i++) {
if (this.currentpage == i) {
str.append("font color=red[" + i
+ "]/font");
} else {
str.append("a href='" + url + "currentpage=" + i
+ "'" + 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("font color=red[" + i
+ "]/font");
} else {
str.append("a href='" + url + "currentpage=" + i
+ "'" + i + "/a");
}
}
}
// 设定是否有下一页的链接
if (this.currentpagethis.pagecount) {
str.append("a href='" + url + "currentpage=" + Nextpage
+ "'下一页/a");
str.append("");
}
// 设定是否有尾页的链接
if (this.pagecount1this.currentpage != this.pagecount) {
str.append("a href='" + url + "currentpage=" + pagecount
+ "'尾页/a");
str.append("");
}
str.append("/tdtd width='3%' /td/tr/table");
} else if (flag.equals(PageDAO.BbsImage)) {
/**
* 论坛形式的分页[以图片的方式体现]
*/
// 设定分页显示的CSS
str.append("style");
str
.append("BODY {FONT-SIZE: 12px;FONT-FAMILY:宋体;WIDTH: 60%; PADDING-LEFT: 25px;}");
str
.append("DIV.meneame {PADDING-RIGHT: 3px; PADDING-LEFT: 3px; FONT-SIZE: 80%; PADDING-BOTTOM: 3px; MARGIN: 3px; COLOR: #ff6500; PADDING-TOP: 3px; TEXT-ALIGN: center}");
str
.append("DIV.meneame A {BORDER-RIGHT: #ff9600 1px solid; PADDING-RIGHT: 7px; BACKGROUND-POSITION: 50% bottom; BORDER-TOP: #ff9600 1px solid; PADDING-LEFT: 7px; BACKGROUND-IMAGE: url('"
+ this.request.getContextPath()
+ "/meneame.jpg'); PADDING-BOTTOM: 5px; BORDER-LEFT: #ff9600 1px solid; COLOR: #ff6500; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ff9600 1px solid; TEXT-DECORATION: none}");
str
.append("DIV.meneame A:hover {BORDER-RIGHT: #ff9600 1px solid; BORDER-TOP: #ff9600 1px solid; BACKGROUND-IMAGE: none; BORDER-LEFT: #ff9600 1px solid; COLOR: #ff6500; BORDER-BOTTOM: #ff9600 1px solid; BACKGROUND-COLOR: #ffc794}");
str
.append("DIV.meneame SPAN.current {BORDER-RIGHT: #ff6500 1px solid; PADDING-RIGHT: 7px; BORDER-TOP: #ff6500 1px solid; PADDING-LEFT: 7px; FONT-WEIGHT: bold; PADDING-BOTTOM: 5px; BORDER-LEFT: #ff6500 1px solid; COLOR: #ff6500; MARGIN-RIGHT: 3px; PADDING-TOP: 5px; BORDER-BOTTOM: #ff6500 1px solid; BACKGROUND-COLOR: #ffbe94}");
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}");

推荐阅读