<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="me.domain.Classes" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!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 class="">
<!-- 分页操作-->
<%
ArrayList<Classes> list = (ArrayList<Classes>)request.getSession().getAttribute("clist"); //此处是取出所存储的数据
int page_current = 1; //当前页数
int page_begin = 0; //起始点,注意:下标从0开始
int page_end = 9; //终点,每页十条信息
int total_count = 0;
if(list != null)
total_count = list.size(); //信息的总量
int page_total = total_count / 10 + (total_count % 10 != 0 ? 1 : 0);
if(request.getParameter("begin") != null) {
page_current = Integer.parseInt(request.getParameter("begin")); //获取当前页数
}
page_begin = (page_current - 1) * 10;
page_end = page_begin + 9 > total_count ? total_count : page_begin + 9;
request.getSession().setAttribute("page_current", page_current); //保存到session中
request.getSession().setAttribute("page_total", page_total);
%>
<!--content-->
<c:forEach var="p" items="${clist}" begin="<%=page_begin %>" end="<%=page_end %>">
<tr>
<td>${p.cid}</td>
<td>${p.cname}</td>
<td>${p.grade }</td>
</tr>
</c:forEach>
<c:if test="${sessionScope.page_current != 1 }">
<li><a href="/StuSys/showAllClasses.jsp?begin=${sessionScope.page_current - 1 }">Prev</a></li>
</c:if>
<c:if test="${sessionScope.page_current != sessionScope.page_total }">
<li><a href="/StuSys/showAllClasses.jsp?begin=${sessionScope.page_current + 1 }">Next</a></li>
</c:if>
当前页数 : ${sessionScope.page_current } / ${sessionScope.page_total }
</body>
</html>