jsp paging

<%@ tag body-content="scriptless" display-name="pagging" pageEncoding="UTF-8"  %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ attribute name="path" required="true" description="请求的路径"%>
<%@ attribute name="count" required="true" description="总页数"%>
<%@ attribute name="page" required="true" description="当前页数"%>
<%@ attribute name="size" required="true" description="每页显示条数"%>
<%@ attribute name="borderColor" description="边框颜色"%>
<%@ attribute name="backColor" description="背景颜色"%>
<%@ attribute name="selectColor" description="选中的背景颜色" %>

<script type="text/javascript">
    function getCheck(path)
       {
      if(path.indexOf('?')==-1)
        return path+"?";
      else
        return path+"&";
   }
  
   function buttonClick(theButton)
   {
      location.href=getCheck("${path}")+"page="+theButton.value+"&size="+${size};
   }
  
   function goClick()
   {
      var theValue = document.getElementById("textNum").value;
      if(parseInt(theValue)<1||parseInt(theValue)>${count})
      {
         alert("您输入的页数超出总页数!");
      }else{
         location.href=path+"page="+theValue;
      }
   }  
   function goClick2(isBack)
   {
      if(isBack)
      {
         if(${page}>1)
         {
            location.href=getCheck("${path}")+"page="+(${page}-1)+"&size="+${size};
         }else
         {
            document.getElementById("btnUp").disabled="disabled";
         }
      }else
      {
         if(${page}<${count})
         {
            location.href=getCheck("${path}")+"page="+(${page}+1)+"&size="+${size};;
         }else
         {
            document.getElementById("btnNext").disabled="disabled";
         }
      }
   }
</script>
<!------------------------------------------>
<c:set var="startSize" value="1" />
<c:set var="endSize" value="10"/>
<c:if test="${count<=10}">
   <c:set var="endSize" value="${count}"/>
</c:if>
<c:if test="${count>10}">
    <c:if test="${page-4>0&&page+5<=count}">
      <c:set var="startSize" value="${page-4}" />
      <c:set var="endSize" value="${page+5}"/>
    </c:if>
    <c:if test="${page+5>count}">
         <c:set var="startSize" value="${count-9}" />
         <c:set var="endSize" value="${count}"/>
    </c:if>
</c:if>
<!------------------------------------------>


<table border="0" cellpadding="0" cellspacing="0" class="fun">
  <tr>
     <td><input id="btnUp" type="button" width="80px" value="上一页" class="buttom" οnclick="goClick2(true)"/><td>
     <c:forEach var="curNum" begin="${startSize}" end="${endSize}" step="1">
         <c:if test="${page==curNum}">
         <td><input type="button" value="${curNum}" class="buttomSelect"/><td>
         </c:if>
         <c:if test="${page!=curNum}">
         <td><input type="button" value="${curNum}" class="buttom" οnclick="buttonClick(this)"/><td>
         </c:if>
     </c:forEach>
     <td><input id="btnNext" type="button" width="80px" value="下一页" class="buttom" οnclick="goClick2(false)"/><td>
     <td>
        <select id="textNum" class="textborder" οnchange="buttonClick(this)">
           <c:forEach var="indexValue" begin="1" end="${count}" step="1">
             <c:if test="${indexValue==page}">
                 <option value="${indexValue}" selected>第${indexValue}页</option>
             </c:if>
             <c:if test="${indexValue!=page}">
                 <option value="${indexValue}">第${indexValue}页</option>
             </c:if>
           </c:forEach>
        </select>
     <td>
  </tr>
</table>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值