免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項超值服

開通VIP
jsp分頁控件

1.PagingTag.java

 

Pagingtag.java代碼  
  1. package com.cn.cosoft.util.taglibs;  
  2.   
  3. import javax.servlet.jsp.JspException;  
  4. import javax.servlet.jsp.tagext.TagSupport;  
  5.   
  6. /** */  
  7. /**  
  8.  * 自定義的分頁標(biāo)簽  
  9.  *  
  10.  * @author 馬萬林  
  11.  *  
  12.  */  
  13. public class PagingTag extends TagSupport {  
  14.   
  15.     private String url = null;  
  16.     private int pageIndex;  
  17.     private int pageMax;  
  18.   
  19.     public void setUrl(String url) {  
  20.         this.url = url;  
  21.     }  
  22.   
  23.     public String getUrl() {  
  24.         return this.url;  
  25.     }  
  26.   
  27.     public void setPageIndex(int pageIndex) {  
  28.         this.pageIndex = pageIndex;  
  29.     }  
  30.   
  31.     public int getPageIndex() {  
  32.         return this.pageIndex;  
  33.     }  
  34.   
  35.     public void setPageMax(int pageMax) {  
  36.         this.pageMax = pageMax;  
  37.     }  
  38.   
  39.     public int getPageMax() {  
  40.         return this.pageMax;  
  41.     }  
  42.   
  43.   
  44.     @Override  
  45.     public int doStartTag() throws JspException {  
  46.         String str = "";  
  47.         if (pageIndex == 1) {  
  48.             str += "首頁 上一頁 ";  
  49.         } else {  
  50.             str += " <a href='" + url + "pageIndex=1'>首頁</a> "  
  51.                     + "<a href='" + url + "pageIndex=" + (pageIndex - 1) + "'>上一頁</a> ";  
  52.         }  
  53.         if (pageIndex / 6 < 1.0 || pageMax < 10) {  
  54.             for (int i = 1; i <= 9; i++) {  
  55.                 if (i <= pageMax) {  
  56.                     if (pageIndex != i) {  
  57.                         str += "<a href='" + url + "pageIndex=" + i + "'>[" + i + "]</a> ";  
  58.                     } else {  
  59.                         str += "  " + i + " ";  
  60.                     }  
  61.                 }  
  62.             }  
  63.         } else if (pageIndex / 6 >= 1.0 && pageMax >= 10) {  
  64.             int fri = 0;  
  65.             int max = 0;  
  66.             if (pageMax - pageIndex > 4) {  
  67.                 fri = pageIndex - 4;  
  68.                 max = pageIndex + 4;  
  69.             } else {  
  70.                 fri = pageMax - 8;  
  71.                 max = pageMax;  
  72.             }  
  73.             for (int i = fri; i <= max; i++) {  
  74.                 if (i <= pageMax) {  
  75.                     if (pageIndex != i) {  
  76.                         str += "<a href='" + url + "pageIndex=" + i + "'>[" + i + "]</a> ";  
  77.                     } else {  
  78.                         str += "  " + i + " ";  
  79.                     }  
  80.                 }  
  81.             }  
  82.         }  
  83.         if (pageIndex == pageMax || pageMax < 2) {  
  84.             str += "下一頁 尾頁";  
  85.         } else {  
  86.             str += "<a href='" + url + "pageIndex=" + (pageIndex + 1) + "'>下一頁</a> "  
  87.                     + "<a href='" + url + "pageIndex=" + pageMax + "'>尾頁</a>";  
  88.         }  
  89.         try {  
  90.             if (str != "") {  
  91.                 pageContext.getOut().write(str);  
  92.             }  
  93.         } catch (Exception e) {  
  94.             throw new JspException(e);  
  95.         }  
  96.         return EVAL_PAGE;  
  97.     }  
  98. }  

 2.pagingTag.tld

 

2.pagingtag.tld代碼  
  1. <?xml  version="1.0"  encoding="utf-8"  ?>  
  2.  <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">  
  3. <taglib>  
  4.     <tlib-version>1.0</tlib-version>  
  5.     <jsp-version>1.2</jsp-version>  
  6.     <short-name>pagingTag</short-name>  
  7.     <!--OutputTag-->  
  8.     <tag>  
  9.         <name>pageOut</name>  
  10.         <tag-class>com.cn.cosoft.util.taglibs.PagingTag</tag-class>  
  11.         <body-content>empty</body-content>  
  12.         <attribute>  
  13.             <name>url</name>  
  14.             <required>true</required>  
  15.             <rtexprvalue>true</rtexprvalue>  
  16.         </attribute>  
  17.         <attribute>  
  18.             <name>pageIndex</name>  
  19.             <required>true</required>  
  20.             <rtexprvalue>true</rtexprvalue>  
  21.         </attribute>  
  22.         <attribute>  
  23.             <name>pageMax</name>  
  24.             <required>true</required>  
  25.             <rtexprvalue>true</rtexprvalue>  
  26.         </attribute>  
  27.     </tag>  
  28. </taglib>  

 3.index.jsp

 

Html代碼  
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>  
  2. <%@taglib uri="/WEB-INF/pagingTag.tld" prefix="pt"%>  
  3.   
  4. <html>  
  5.     <body >  
  6.   
  7.   <pt:pageOut url="當(dāng)前頁面路徑?" pageIndex="當(dāng)前分頁頁碼"  
  8.                                 pageMax="總的分頁頁碼" ></pt:pageOut>    
  9.   
  10. </body>  
  11.   
  12. </html>  
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Struts2中實(shí)現(xiàn)自定義分頁標(biāo)簽
Struts2分頁實(shí)例
struts2 自定義分頁標(biāo)簽組件
jsp 分頁
手把手教你做一個自定義表格標(biāo)簽
實(shí)現(xiàn)千萬級數(shù)據(jù)分頁的存儲過程!《
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服