程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> jsp分頁

jsp分頁

編輯:關於JSP

  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("';");

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved