熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

jsp分頁技術編碼

2013-11-23 19:05:36  來源: Java核心技術 

  public static final String splitPages(int thePage String queryString int count

  int pageLength)

  {

  int maxPage = count / pageLength + ;

  int prevPage = thePage ;

  if (prevPage < )

  {

  prevPage = ;

  }

  int nextPage = thePage + ;

  int showMaxPage = thePage + ;

  int spacePage = ;

  if (thePage > )

  {

  spacePage = thePage ;

  }

  if (showMaxPage < )

  {

  showMaxPage = ;

  }

  //<p class=fy><a class=back >上一頁</a><a ></a><a ></a><a ></a><a class=next >下一頁</a></p>

  StringBuffer sb = new StringBuffer();

  sbappend(<p class=\fy\> <a href=\+queryString+\>第一頁</a>);

  sbappend(<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;

  }

  sbappend(<a href=\ + queryString + &pagex= + i

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

  + </font></a>);

  }

  sbappend(<a class=\next\ href=\ + queryString + &pagex= + nextPage

  + \>下一頁</a>);

  sbappend( <a href=\ + queryString + &pagex= + maxPage

  + \>最後頁</a>);

  sbappend(</p>);

  return sbtoString();

  }

  public static final String splitPages(int thePage String queryString int count

  int pageLength)

  {

  int maxPage = count / pageLength + ;

  int prevPage = thePage ;

  if (prevPage < )

  {

  prevPage = ;

  }

  int nextPage = thePage + ;

  int showMaxPage = thePage + ;

  int spacePage = ;

  if (thePage > )

  {

  spacePage = thePage ;

  }

  if (showMaxPage < )

  {

  showMaxPage = ;

  }

  //<p class=fy><a class=back >上一頁</a><a ></a><a ></a><a ></a><a class=next >下一頁</a></p>

  StringBuffer sb = new StringBuffer();

  sbappend(<p class=\fy\> <a href=\+queryString+\>第一頁</a>);

  sbappend(<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;

  }

  sbappend(<a href=\ + queryString + &pagex= + i

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

  + </font></a>);

  }

  sbappend(<a class=\next\ href=\ + queryString + &pagex= + nextPage

  + \>下一頁</a>);

  sbappend( <a href=\ + queryString + &pagex= + maxPage

  + \>最後頁</a>);

  sbappend(</p>);

  return sbtoString();

  }
    thePage為第幾頁queryString為鏈接字符串count為取得的數據總數pageLength為每頁顯示多少條數據


From:http://tw.wingwit.com/Article/program/Java/hx/201311/26259.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.