jsp通用分页实现脚本

工具脚本使用时只需替换url的问号前半部分即可。
此页面需要jstl标签库的支持,在页头导入jstl标签:
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>


js代码:
<script>
		//进入指定页面
		function goPage(){
			var box=document.getElementById('pageSelect');
			var pn='';
			for(var i=0; i<box.options.length; i++) {
			    if(box.options[i].selected) { 
			      pn=box.options[i].value;
			    }
			  }
			window.location='airCompanySettingAction!showAirCompanyList.action?pageSize=${pageSize}&pageNum='+pn;
		}
</script>



放在数据表格下面的脚本:
	<div class="page con"> 
   	    <c:choose>
   	    <c:when test="${cpage == 1}">
   	     <span class="disabled"> 第一页 </span>
          <span class="disabled"> 上一页 </span>
		</c:when>
		<c:otherwise>
		<a href="airCompanySettingAction!showAirCompanyList.action?pageNum=1&pageSize=${pageSize}">第一页</a>
		<a href="airCompanySettingAction!showAirCompanyList.action?pageNum=${pageNum-1}&pageSize=${pageSize}">上一页</a>
		</c:otherwise>
		</c:choose>
		&nbsp;&nbsp;<span>${cpage}</span>&nbsp;&nbsp;

	    <c:choose>
	     <c:when test="${cpage==pageCount}">
	     <span class="disabled">下一页 </span>
	     <span class="disabled">最后页 </span>
	     </c:when>
	     <c:otherwise>
		<a href="airCompanySettingAction!showAirCompanyList.action?pageNum=${pageNum+1}&pageSize=${pageSize}">下一页</a>
		<a href="airCompanySettingAction!showAirCompanyList.action?pageNum=${pageCount}&pageSize=${pageSize}">最后页</a>
	    </c:otherwise>
		</c:choose>
		&nbsp;
		<select name="pageSelect" id="pageSelect">
			<c:forEach items="${pageList}" var="p" varStatus="s">
			<option value="${p}">${p}/${pageCount}</option>
			</c:forEach>
		</select>
		<input type="button" value="GO" onclick="goPage();" />
		</div>

你可能感兴趣的:(JavaScript,jsp)