jsp分页技术编码

2008-07-22 13:03:00.0     浏览:1825     来源:中国IT实验室
关键词:  jsp     分页  

public static final String splitPages2(int thePage, String queryString, int count,

int pageLength)

{

int maxPage = count / pageLength + 1;

int prevPage = thePage - 1;

if (prevPage < 1)

{

prevPage = 1;

}

int nextPage = thePage + 1;

int showMaxPage = thePage + 6;

int spacePage = 1;

if (thePage > 6)

{

spacePage = thePage - 5;

}

if (showMaxPage < 10)

{

showMaxPage = 10;

}

//

上一页010203下一页

StringBuffer sb = new StringBuffer();

sb.append("

第一页");

sb.append("

+ "\">上一页");

for (int i = spacePage; i < showMaxPage && i <= maxPage; i++)

{

String fontColor = "black";

if (i == thePage)

{

fontColor = "red";

}

sb.append("

+ "\">" + addzero(i, 2)

+ "");

}

[第1页]   [第2页]   [下一页]