分页查询代码java java分页查询原理思路( 二 )


.getParameter("currentpage"));
} else {
this.currentpage = 1;
}
} catch (Exception ex) {
this.currentpage = 1;
}
return this.currentpage;
}
/**
* 分页工具条
*
* @param fileName
*String
* @return String
*/
public String pagetool(String flag) {
StringBuffer str = new StringBuffer();
String url = this.getParamUrl();
int ProPage = this.currentpage - 1;
int Nextpage = this.currentpage + 1;
// 文字分页查询代码java的分页
if (flag.equals(PageDAO.Text)) {
str.append("form method='post' name='pageform' action=''");
str
.append("table style='color: windowframe' width='100%' border='0' cellspacing='0' cellpadding='0'");
str.append("tr");
str.append("td width='20%'/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(" ");
str.append("a href='" + url + "currentpage=" + ProPage
+ "'上一页/a");
str.append(" ");
} else {
str.append("首页");
str.append(" ");
str.append("上一页");
str.append(" ");
}
if (this.currentpagethis.pagecount) {
str.append("a href='" + url + "currentpage=" + Nextpage
+ "'下一页/a");
str.append(" ");
} else {
str.append("下一页");
str.append(" ");
}
if (this.pagecount1this.currentpage != this.pagecount) {
str.append("a href='" + url + "currentpage=" + pagecount
+ "'尾页/a");
str.append(" ");
} else {
str.append("尾页");
str.append(" ");
}
str.append("转到");
str
.append("select name='currentpage' onchange='javascript:ChangePage(this.value);'");
for (int j = 1; j = pagecount; j++) {
str.append("option value='" + j + "'");
if (currentpage == j) {
str.append("selected");
}
str.append("");
str.append("" + j + "");
str.append("/option");
}
str.append("/select页");
str.append("/tdtd width='3%' /td/tr/table");
str.append("script language='javascript'");
str.append("function ChangePage(testpage){");
str.append("document.pageform.action='" + url
+ "currentpage='+testpage+'';");
str.append("document.pageform.submit();");
str.append("}");
str.append("/script");
str.append("/form");
} else if (flag.equals(PageDAO.Image)) {
/**
* 图片的分页
*/
} else if (flag.equals(PageDAO.BbsText)) {
/**
* 论坛形式的分页[直接以数字方式体现]
*/
str
.append("table width='100%' border='0' cellspacing='0' cellpadding='0'");
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

推荐阅读