@ -1,10 +1,3 @@
<%--
Created by IntelliJ IDEA.
User: user
Date: 2020/2/10
Time: 21:45
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html class="x-admin-sm">
@ -13,21 +6,16 @@
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<!-- 引入外部CSS文件 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.1.1.js"></script>
<script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.1.1.js"></script>
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<%-- 注释掉的导航栏代码 --%>
<%--<div class="x-nav">
<span class="layui-breadcrumb">
<a href="">首页</a>
@ -35,14 +23,16 @@
<a>
<cite>导航元素</cite></a>
</span>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick= "location.reload()" title="刷新">
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" "location.reload()" title="刷新">
<i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>--%>
<div class="layui-fluid">
<div class="layui-row layui-col-space15">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body ">
<!-- 注释掉的搜索表单代码 -->
<%--<form id="myform" class="layui-form layui-col-space5">
<div class="layui-inline layui-show-xs-block">
<input class="layui-input" type="text" autocomplete="off" placeholder="请输入关键字" name="keyword" id="keyword" value="${param.keyword}">
@ -56,10 +46,13 @@
</form>--%>
</div>
<xblock>
<!-- 添加学生按钮 -->
<a href="${pageContext.request.contextPath}/student/addStudent" class="layui-btn layui-btn-normal"><i class="layui-icon"></i>添加</a>
<!-- 显示总数据条数 -->
<span class="x-right" style="line-height:40px">共有数据:${pageInfo.total} 条</span>
</xblock>
<div class="layui-card-body">
<!-- 表格展示学生信息 -->
<table class="layui-table layui-form">
<thead>
<tr style="text-align: center">
@ -73,40 +66,47 @@
<th style="text-align: center">育人导师</th>
<th style="text-align: center">状态</th>
<th style="text-align: center">操作</th>
</tr>
</thead>
<tbody>
<%
int j = 1;
int j = 1; // 初始化行号计数器
%>
<!-- 遍历学生列表并生成表格行 -->
<c:forEach items="${pageInfo.list}" var="student">
<tr id="light" style="text-align: center">
<td><%=j++%></td>
<td>${student.name}</td>
<td>${student.sex}</td>
<td>${student.sno}</td>
<td>${student.stu_class}</td>
<td>${student.phone}</td>
<td>${student.dorm_id}</td>
<td>${student.teacher}</td>
<td><%=j++%></td> <!-- 显示行号 -->
<td>${student.name}</td> <!-- 显示学生姓名 -->
<td>${student.sex}</td> <!-- 显示学生性别 -->
<td>${student.sno}</td> <!-- 显示学生学号 -->
<td>${student.stu_class}</td> <!-- 显示学生班级 -->
<td>${student.phone}</td> <!-- 显示学生联系方式 -->
<td>${student.dorm_id}</td> <!-- 显示学生宿舍号 -->
<td>${student.teacher}</td> <!-- 显示学生育人导师 -->
<!-- 根据学生状态显示不同按钮 -->
<c:if test="${student.status == 1}">
<td><button class="layui-btn layui-btn-normal layui-btn-sm">已激活</button></td>
</c:if>
<c:if test="${student.status == 0}">
<td><button class="layui-btn layui-btn-danger layui-btn-sm">禁用</button></td>
</c:if>
<!-- 编辑按钮 -->
<td class="td-manage">
<a title="编辑" href="${pageContext.request.contextPath}/student/editStudent?sno=${student.sno}">
<i class="layui-icon"></i>
</a>
</td>
</tr>
</c:forEach>
</tr>
</tbody>
</table>
</div>
<div class="pull-left">
<!-- 左侧浮动的分页信息 -->
<div class="form-group form-inline">
共 ${pageInfo.pages} 页 当前页:${pageInfo.pageNum} / ${pageInfo.pages}  每页
<!-- 下拉框用于选择每页显示的条数 -->
<select class="form-control" id="changePageSize" onchange="changePageSize()">
<option value="1">${pageInfo.size}</option>
<option value="5">5</option>
@ -116,50 +116,57 @@
</select> 条
</div>
</div>
<c:choose>
<!-- 根据总页数和当前页码设置分页按钮的范围 -->
<c:when test="${pageInfo.pages < 5}">
<c:set var="begin" value="1">
</c:set>
<c:set var="end" value="${pageInfo.pages}">
</c:set>
<!-- 如果总页数小于5, 则显示所有页码 -->
<c:set var="begin" value="1"></c:set>
<c:set var="end" value="${pageInfo.pages}"></c:set>
</c:when>
<c:when test="${pageInfo.pageNum <= 3}">
<c:set var="begin" value="1">
</c:set>
<c:set var="end" value="5">
</c:set>
<!-- 如果当前页码小于等于3, 则显示前5页 -->
<c:set var="begin" value="1"></c:set>
<c:set var="end" value="5"></c:set>
</c:when>
<c:when test="${pageInfo.pageNum > 3 and pageInfo.pageNum <= pageInfo.pages-2}">
<c:set var="begin" value="${pageInfo.pageNum - 2}">
</c:set>
<c:set var="end" value="${pageInfo.pageNum + 2}">
</c:set>
<!-- 如果当前页码大于3且小于总页数减2, 则显示当前页码前后各两页 -->
<c:set var="begin" value="${pageInfo.pageNum - 2}"></c:set>
<c:set var="end" value="${pageInfo.pageNum + 2}"></c:set>
</c:when>
<c:otherwise>
<c:set var="begin" value="${pageInfo.pages - 4}">
</c:set>
<c:set var="end" value="${pageInfo.pages}">
</c:set>
<!-- 其他情况, 显示最后4页 -->
<c:set var="begin" value="${pageInfo.pages - 4}"></c:set>
<c:set var="end" value="${pageInfo.pages}"></c:set>
</c:otherwise>
</c:choose>
<div class="layui-card-body x-right" style="height: min-content">
<!-- 右侧浮动的分页导航 -->
<div class="page">
<div>
<!-- 首页链接 -->
<a class="next" href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=${pageInfo.pageSize}&keyword=${param.keyword}">首页</a>
<!-- 上一页链接, 如果当前页码大于1 -->
<c:if test="${pageInfo.pageNum > 1}">
<a class="prev" href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=${pageInfo.pageNum-1}&size=${pageInfo.pageSize}&keyword=${param.keyword}">上一页</a>
</c:if>
<!-- 循环生成页码链接 -->
<c:forEach var="i" begin="${begin}" end="${end}" step="1">
<!-- 当前页码高亮显示 -->
<c:if test="${pageInfo.pageNum == i}">
<span class="current">${i}</span>
</c:if>
<!-- 非当前页码的普通链接 -->
<c:if test="${pageInfo.pageNum != i}">
<a class="num" href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=${i}&size=${pageInfo.pageSize}&keyword=${param.keyword}">${i}</a>
</c:if>
</c:forEach>
<!-- 下一页链接,如果当前页码小于总页数 -->
<c:if test="${pageInfo.pageNum < pageInfo.pages}">
<a class="next" href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=${pageInfo.pageNum+1}&size=${pageInfo.pageSize}&keyword=${param.keyword}">下一页</a>
</c:if>
<!-- 尾页链接 -->
<a class="next" href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=${pageInfo.pages}&size=${pageInfo.pageSize}&keyword=${param.keyword}">尾页</a>
</div>
</div>
@ -168,24 +175,28 @@
</div>
</div>
</div>
<script>
<script>
function changePageSize() {
//获取下拉框的值
// 获取下拉框的值
var pageSize = $("#changePageSize").val();
//向服务器发送请求,改变每页显示条数
location.href = "${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size="+ pageSize;
// 向服务器发送请求,改变每页显示条数
location.href = "${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=" + pageSize;
}
$("#search_btn").click(function () {
alert(1234);
// 获取搜索关键字
var keyword = $("#keyword").val();
alert(keyword);
alert("${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=5&keyword="+keyword);
location.href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=5&keyword="+keyword;
// 向服务器发送请求,进行搜索
location.href = "${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=5&keyword=" + keyword;
});
$("#refresh").click(function () {
// 重置表单并刷新页面
$("#myform").reset();
location.href="${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=5";
location.href = "${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}&page=1&size=5";
});
</script>
</script>
</body>
</html>