JFinal使用JSP写的分页组件

JSP页面是使用JSTL标签写的逻辑。使用方法是,根据页面中定义的<C:SET>的参数,在include分页页面以前传入<c:set>标签中的参数,就可以使用了。

<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>页面数据分页</title>
</head>
<body>
<!-- 定义的变量 -->
<div><!-- 从request中取出传入的参数,放入本页变量中 -->
<c:set var="pageNumber" scope="page" value="${requestScope.pageNumber}" /> 
<c:set var="pageSize" scope="page" value="${requestScope.pageSize}" /> 
<c:set var="totalPage" scope="page" value="${requestScope.totalPage}" /> 
<c:set var="totalRow" scope="page" value="${requestScope.totalRow}" /> 
<c:set var="pageUrl" scope="page" value="${requestScope.pageUrl}" /> 
<!-- 分页逻辑 -->
<!-- 上一页标签 -->
<p class="green-black ">
总共
 &nbsp;&nbsp;
${totalPage }
&nbsp;&nbsp;
页
&nbsp;&nbsp;&nbsp;
<c:if test="${pageNumber<=1}">
	<span>上一页</span>&nbsp;&nbsp;
</c:if> 
<c:if test="${pageNumber>1}">
	<a href="${pageUrl}${pageNumber-1}">上一页</a>
</c:if> 
当前第
&nbsp;&nbsp;
${pageNumber}
&nbsp;&nbsp;
页
&nbsp;&nbsp; 
<c:if test="${pageNumber==totalPage}">
	<span>下一页</span>
</c:if> 
<c:if test="${pageNumber!=totalPage}">
	<a href="${pageUrl}${pageNumber+1}">下一页</a>
</c:if>
&nbsp;&nbsp; 
<span>选择:</span>
<select name="pageSelect" onchange="window.location.href=this.options[selectedIndex].value">
	<c:forEach var="i" begin="1" end="${totalPage}" step="1">
		<c:if test="${i==pageNumber}">
			<option value="${pageUrl}${i}" selected>${i}</option>
		</c:if>
		<c:if test="${i!=pageNumber}">
			<option value="${pageUrl}${i}">${i}</option>
		</c:if>
	</c:forEach>
</select>
</p>
</div>
</body>
</html>
使用案例
 <c:set var="pageNumber" scope="request" value="${appList.pageNumber}" />
<c:set var="pageSize" scope="request" value="${appList.pageSize}" />
<c:set var="totalPage" scope="request" value="${appList.totalPage}" />
<c:set var="totalRow" scope="request" value="${appList.totalRow}" />
<c:set var="pageUrl" scope="request" value="${contxt}/appinfo/" />
<tr>
 <td colspan="8"><jsp:include page="comm/page.jsp" /></td><!--使用JSP的include标签引入分页页面-->
 </tr>  

你可能感兴趣的:(@JFinal)