前端分页代码展示
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
pageContext.setAttribute("APP_PATH",request.getContextPath());
%>
<!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>
<!--要先引入jquery 再引入 bootstrap 不然报错:Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6 -->
<script type="text/javascript" src="${APP_PATH }/static/js/jquery-1.12.4.min.js"></script>
<!-- 引入bootstrap的js和样式 -->
<script type="text/javascript" src="${APP_PATH }/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="${APP_PATH }/static/bootstrap-3.3.7-dist/css/bootstrap.min.css">
</head>
<body>
<h3 align="center" >客户列表</h3>
<table border="1" width="70%" align="center">
<tr>
<td style="text-align: center;">序号</td>
<td style="text-align: center;">姓名</td>
<td style="text-align: center;">性别</td>
<td style="text-align: center;">邮箱</td>
</tr>
<c:forEach items="${pageInfo.list }" var="s" varStatus="ss">
<tr>
<td align="center">${ss.count}</td>
<td align="center">${s.empName}</td>
<td align="center">${s.gender}</td>
<td align="center">${s.email}</td>
</tr>
</c:forEach>
</table>
<br/>
<center>
<ul class="pagination">
<!-- <li><a href="test?page=1">首页</a></li> -->
<c:if test="${pageInfo.pageNum>1}">
<li><a href="test?page=${pageInfo.pageNum-1}">上一页</a></li>
</c:if>
<c:choose>
<c:when test="${pageInfo.pages<=7}">
<c:set var="begin" value="1"/>
<c:set var="end" value="${pageInfo.pages}"/>
</c:when>
<c:otherwise>
<c:set var="begin" value="${pageInfo.pageNum-3}"/>
<c:set var="end" value="${pageInfo.pageNum+3}"/>
<%--头溢出--%>
<c:if test="${begin<1}">
<c:set var="begin" value="1"/>
<c:set var="end" value="7"/>
</c:if>
<%--尾溢出--%>
<c:if test="${end>pageInfo.pages}">
<c:set var="begin" value="${pageInfo.pages-6}"/>
<c:set var="end" value="${pageInfo.pages}"/>
</c:if>
</c:otherwise>
</c:choose>
<%--循环遍历页码列表--%>
<c:forEach var="i" begin="${begin}" end="${end}">
<c:choose>
<c:when test="${i eq pageInfo.pageNum}">
<li class="page-item active"><a>${i}</a></li>
</c:when>
<c:otherwise>
<li><a href="test?page=${i}">${i}</a></li>
</c:otherwise>
</c:choose>
</c:forEach>
<c:if test="${pageInfo.pageNum<pageInfo.pages}">
<li><a href="test?page=${pageInfo.pageNum+1}">下一页</a></li>
</c:if>
<%-- <li><a href="test?page=${pageInfo.pages}">尾页</a></li> --%>
</ul>
</center>
<br>
<tr>
<td>第${pageInfo.pageNum}页/共${pageInfo.pages}页</td>>
<td>每页显示:
<select id="size">
<option value="10" οnclick="size(10)">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>
</td>
</tr>
<script type="text/javascript">
function size(size) {
$.ajax({
type: 'get',
url: 'test?size=' + size
});
}
</script>
</body>
</html>
还没有评论,来说两句吧...