点击这里给我发消息 点击这里给我发消息

jsp分页技术代码奉献

添加时间:2013-12-6
    相关阅读: 技术 链接
副标题#e#

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;

            }

    //<p class="fy"><a class="back" href="">上一页</a><a href="">01</a><a href="">02</a><a href="">03</a><a class="next" href="">下一页</a></p>

            StringBuffer sb = new StringBuffer();

            sb.append("<p class=\"fy\"> <a href=\""+queryString+"\">第一页</a>");

            sb.append("<a class=\"back\" href=\"" + queryString + "&pagex=" + prevPage

                    + "\">上一页</a>");

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

            {

                String fontColor = "black";

                if (i == thePage)

                {

                    fontColor = "red";

                }

                sb.append("<a href=\"" + queryString + "&pagex=" + i

                        + "\"><font color=" + fontColor + ">" + addzero(i, 2)

                        + "</font></a>");

            }

本文作者: #p#副标题#e#

        sb.append("<a class=\"next\" href=\"" + queryString + "&pagex=" + nextPage

                    + "\">下一页</a>");

            sb.append(" <a href=\"" + queryString + "&pagex=" + maxPage

             + "\">最后页</a>");

            sb.append("</p>");

            return sb.toString();

        }

     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;

      }

    //<p class="fy"><a class="back" href="">上一页</a><a href="">01</a><a href="">02</a><a href="">03</a><a class="next" href="">下一页</a></p>

      StringBuffer sb = new StringBuffer();

      sb.append("<p class=\"fy\"> <a href=\""+queryString+"\">第一页</a>");

      sb.append("<a class=\"back\" href=\"" + queryString + "&pagex=" + prevPage

        + "\">上一页</a>");

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

      {

       String fontColor = "black";

       if (i == thePage)

       {

        fontColor = "red";

       }

       sb.append("<a href=\"" + queryString + "&pagex=" + i

         + "\"><font color=" + fontColor + ">" + addzero(i, 2)

         + "</font></a>");

      }

      sb.append("<a class=\"next\" href=\"" + queryString + "&pagex=" + nextPage

        + "\">下一页</a>");

      sb.append(" <a href=\"" + queryString + "&pagex=" + maxPage

       + "\">最后页</a>");

      sb.append("</p>");

      return sb.toString();

     }
    thePage为第几页,queryString为链接字符串,count为取得的数据总数,pageLength为每页显示多少条数据

本文作者:
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册