在這一個功能中其實主要涉及到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>