java分页加排序代码 java分页page类( 四 )


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中如何实现百度中的分页/**
* 分页代码
*
* @author Star
* @version 1.0 2008/07/08
*/
public class CutPage implements Serializable{
private static Log log = LogFactory.getLog(CutPage.class);
private int curPageNo = 0; // 当前页数 , 从0开始
private int size = 0; // 所有数据条数
private String url; // 页面跳转的路径
private List showList; // 当前页面需要显示的数据列表
private int pageSize = 20;// 每页显示的数据条数
private int groupSize = 1;// 多少页为一组
private String pageNavigation;// 导航条
/**
* 每次通过sql语句从数据库里面分组取出需要显示的数据
*
* @param request
*javax.servlet.http.HttpServletRequest对象
* @param sql
*String 查询数据库的sql语句
* @param pageSize
*int 每页显示的条数
* @param groupSize
*int 分成多少组
* @param url
*String 页面跳转的路径,若没有特殊的参数传递,可以传入null或"",

推荐阅读