jsp分页显示测试

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!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>Insert title here</title>
</head>
<body>
	<c:if test="${empty pageBean.customers }">
		当前页没有数据
	</c:if>
	<c:if test="${not empty pageBean.customers }">
		<h3 style="text-align: center;">当前是  ${pageBean.pageNum } 页数据 列表</h3> 
		<table border="1" width="100%">
			<tr>
				<th>客户姓名</th>
				<th>客户性别</th>
				<th>客户生日</th>
				<th>客户邮箱</th>
				<th>客户手机</th>
				<th>客户爱好</th>
				<th>客户类型</th>
				<th>客户描述</th>
			</tr>
			<c:forEach items="${pageBean.customers }" var="customer">
				<tr>
					<td>${customer.name }</td>
					<td>${customer.gender }</td>
					<td>${customer.birthday }</td>
					<td>${customer.email }</td>
					<td>${customer.cellphone }</td>
					<td>${customer.preference }</td>
					<td>${customer.type }</td>
					<td>${customer.description }</td>
				</tr>
			</c:forEach>
		</table>	
		<br/>
		<!-- 参考 了 百度, 发现 如果当前页是第一页, 那么 就 不显示 首页和上一页  -->
		<div style="text-align: center;">
			<c:if test="${pageBean.pageNum!=1 }">
				<a href="${pageContext.request.contextPath }/pagequery?pagenum=1">首页</a>
				<a href="${pageContext.request.contextPath }/pagequery?pagenum=${pageBean.pageNum-1 }">上一页</a>
			</c:if>
			<!-- 参考 百度, 左 5 右 4, 左边显示 5 个数, 右边显示4 个数  -->
			<c:forEach begin="${pageBean.pageNum-5>0?pageBean.pageNum-5:1 }" end="${pageBean.pageNum+4<pageBean.totalPageNum?pageBean.pageNum+4:pageBean.totalPageNum }" var="i">
				
				<c:if test="${pageBean.pageNum==i }">
					<font color="red">${i }</font>
				</c:if>
				<c:if test="${pageBean.pageNum!=i }">
					<a href="${pageContext.request.contextPath }/pagequery?pagenum=${i }">${i }</a>
				</c:if>
			</c:forEach>
			
			<c:if test="${pageBean.pageNum!=pageBean.totalPageNum }">
				<a href="${pageContext.request.contextPath }/pagequery?pagenum=${pageBean.pageNum+1 }">下一页 </a>
				<a href="${pageContext.request.contextPath }/pagequery?pagenum=${pageBean.totalPageNum }">尾页 </a>
			</c:if>
		</div>
		
	</c:if>
</body>
</html>

原文链接: jsp分页显示测试 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://www.gyarmy.com/post-82.html )

发表评论

0则评论给“jsp分页显示测试”