现在的位置: 首页 > 综合 > 正文

JSP中分页功能的实现

2013年08月21日 ⁄ 综合 ⁄ 共 1150字 ⁄ 字号 评论关闭

在这一个功能中其实主要涉及到4个功能点。

1、首页功能的实现

<a href="javascript:gotoPage(1)" title="首页" style="cursor: hand;">
<img src="${pageContext.request.contextPath}/style/blue/images/pageSelector/firstPage.png"/>

</a>

2、尾页功能的实现

<a href="javascript:gotoPage(${pageCount})" title="尾页" style="cursor: hand;">
<img src="${pageContext.request.contextPath}/style/blue/images/pageSelector/lastPage.png"/>

</a>

3、中间当前页附近页码的实现

<s:iterator begin="%{beginPageIndex}" end="%{endPageIndex}" var="num"><!-- num千万别漏了,它用来记录beginIndex和endPageIndex之间的数--> 
   
  <s:if test="#num == currentPage">
     <span class="PageSelectorNum PageSelectorSelected">${num}</span>
  </s:if>
  <s:else>
     <span class="PageSelectorNum" style="cursor: hand;" onClick="gotoPage(${num});">${num}</span>
  </s:else>
</s:iterator>

4、转到功能的实现

    <select onchange="gotoPage(this.value)">
   <s:iterator begin="1" end="%{pageCount}" var="num" >
      <option value="${num}">${num}</option>
   </s:iterator>
   </select>

 

<!--以下代码实现是“转到“显示为当前页-->

<script type="text/javascript">
$("#_pn").val("${currentPage}");
</script>

5、跳转函数的实现如下

<script type="text/javascript">
           function gotoPage(pageNum){
               window.location.href= "topic_show.action?id=${id}&pageNum="+pageNum;
           }
  </script>


抱歉!评论已关闭.