jsp分頁
public int doStartTag() throws JspException {
StringBuffer sb = null;
if (result != null && result.getContent() != null
&& result.getContent().size() > 0) {
sb = new StringBuffer("分頁: ");
if (result.getPage().getHasPrePage()){
sb.append("<a href='").append(url);
if (url.indexOf("?") == -1)
sb.append("?page=1");
else
sb.append("&page=1");
linkParams(sb);
sb.append("'>").append("首頁").append("</a>").append(" | ");
sb.append("<a href='").append(url);
if (url.indexOf("?") == -1)
sb.append("?page=").append(
result.getPage().getPreviousPage());
else
sb.append("&page=").append(
result.getPage().getPreviousPage());
linkParams(sb);
sb.append("'>").append("上頁").append("</a>").append(" | ");
}
if (result.getPage().getHasNextPage()) {
sb.append("<a href='").append(url);
if (url.indexOf("?") == -1)
sb.append("?page=").append(result.getPage().getNextPage());
else
sb.append("&page=").append(result.getPage().getNextPage());
linkParams(sb);
sb.append("'>").append("下頁").append("</a>").append(" | ");
sb.append("<a href='").append(url);
if (url.indexOf("?") == -1)
sb.append("?page=").append(result.getPage().getTotalPage());
else
sb.append("&page=").append(result.getPage().getTotalPage());
linkParams(sb);
sb.append("'>").append("尾頁").append("</a>");
}
sb
.append(" 跳轉到:<select name='goToPage' onchange='javascript:goPage(this.value)'>");
int s = result.getPage().getTotalCount();
for (int i = 1; i <= s; i++) {
sb.append("<option value=").append(i);
if (Integer.parseInt(page) == i)
sb.append(" selected");
sb.append(">第").append(i).append("頁</option>");
}
sb.append("</select>");
sb.append("<script language=javascript>");
sb.append("function goPage(page){").append("window.location='")
.append(url);
if (url.indexOf("?") == -1)
sb.append("?page='+").append("page");
else
sb.append("&page='+").append("page");
sb.append("+'");
linkParams(sb);
sb.append("';");