pull/1/head
shen 3 months ago
parent 7f3aa64603
commit e87530308b

@ -7,88 +7,87 @@ import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
/** /**
* Description: * Description:
*
* @Date: 2020/2/17 14:19
* @Author: PeiChen
*/ */
@Repository @Repository
public interface StudentDao {//frrr public interface StudentDao {
/** /**
* *
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Select("select * from students") @Select("select * from students")
List<Student> findAll() throws Exception; List<Student> findAll() throws Exception;
/** /**
* sno * sno
* @return * @param sno
* @throws Exception * @return
* @throws Exception
*/ */
@Select("select * from students where sno = #{sno}") @Select("select * from students where sno = #{sno}")
Student findBySno(String sno) throws Exception; Student findBySno(String sno) throws Exception;
/** /**
* *
* @return * @param keyword
* @throws Exception * @return
* @throws Exception
*/ */
@Select("select * from students where name like '%${keyword}%' or sex like '%${keyword}%' or sno like '%${keyword}%' or stu_class like '%${keyword}%' or phone like '%${keyword}%' or place like '%${keyword}%' or dorm_id like '%${keyword}%' or teacher like '%${keyword}%' ") @Select("select * from students where name like '%${keyword}%' or sex like '%${keyword}%' or sno like '%${keyword}%' or stu_class like '%${keyword}%' or phone like '%${keyword}%' or place like '%${keyword}%' or dorm_id like '%${keyword}%' or teacher like '%${keyword}%' ")
List<Student> search(@Param(value = "keyword") String keyword) throws Exception; List<Student> search(@Param(value = "keyword") String keyword) throws Exception;
/** /**
* *
* @param student * @param student
* @throws Exception * @throws Exception
*/ */
@Insert("insert into students(name, sex, sno, stu_class, phone, place, dorm_id, teacher, status) values(#{name},#{sex},#{sno},#{stu_class},#{phone},#{place},#{dorm_id},#{teacher},#{status})") @Insert("insert into students(name, sex, sno, stu_class, phone, place, dorm_id, teacher, status) values(#{name},#{sex},#{sno},#{stu_class},#{phone},#{place},#{dorm_id},#{teacher},#{status})")
void add(Student student) throws Exception; void add(Student student) throws Exception;
/** /**
* id *
* @param sno * @param sno
* @throws Exception * @throws Exception
*/ */
@Delete("delete from students where sno = #{sno}") @Delete("delete from students where sno = #{sno}")
void delete(String sno) throws Exception; void delete(String sno) throws Exception;
/** /**
* id *
* @param student * @param student
* @throws Exception * @throws Exception
*/ */
@Update("update students set name = #{name},sex = #{sex},sno = #{sno},stu_class = #{stu_class},phone = #{phone},place = #{place},dorm_id = #{dorm_id},teacher = #{teacher},status = #{status} where id = #{id}") @Update("update students set name = #{name},sex = #{sex},sno = #{sno},stu_class = #{stu_class},phone = #{phone},place = #{place},dorm_id = #{dorm_id},teacher = #{teacher},status = #{status} where id = #{id}")
void update(Student student) throws Exception; void update(Student student) throws Exception;
/** /**
* 宿status宿 * 宿
* @param dorm_id * @param dorm_id 宿
* @return * @param status
* @throws Exception * @return
* @throws Exception
*/ */
@Select("select * from students where dorm_id = #{dorm_id} and status = #{status}") @Select("select * from students where dorm_id = #{dorm_id} and status = #{status}")
List<Student> findByDormId(@Param(value = "dorm_id") String dorm_id,@Param(value = "status") Integer status) throws Exception; List<Student> findByDormId(@Param(value = "dorm_id") String dorm_id,@Param(value = "status") Integer status) throws Exception;
/** /**
* teacher *
* @param teacher * @param teacher
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Select("select * from students where teacher = #{teacher}") @Select("select * from students where teacher = #{teacher}")
List<Student> findByTeacher(String teacher) throws Exception; List<Student> findByTeacher(String teacher) throws Exception;
/** /**
* *
* @param teacher * @param teacher
* @param keyword * @param keyword
* @return * @return
* @throws Exception * @throws Exception
*/ */
@Select("select * from students where teacher = #{teacher} and sno = #{keyword} ") @Select("select * from students where teacher = #{teacher} and sno = #{keyword} ")
List<Student> searchStudent(@Param(value = "teacher") String teacher,@Param(value = "keyword") String keyword) throws Exception; List<Student> searchStudent(@Param(value = "teacher") String teacher,@Param(value = "keyword") String keyword) throws Exception;
} }

@ -3,26 +3,26 @@ package cn.ppdxzz.domain;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Description: * Student
* * Serializable
* @Date: 2020/2/17 14:08
* @Author: PeiChen
*/ */
public class Student implements Serializable { public class Student implements Serializable {
private Integer id; private Integer id; // 学生的唯一标识符
private String name;//姓名 private String name; // 学生的姓名
private String sex;//性别 private String sex; // 学生的性别
private String sno;//学号 private String sno; // 学生的学号
private String stu_class;//班级 private String stu_class; // 学生所在的班级
private String phone;//联系方式 private String phone; // 学生的联系电话
private String place;//家庭住址 private String place; // 学生的家庭住址
private String dorm_id;//宿舍号 private String dorm_id; // 学生宿舍的编号
private String teacher;//育人导师 private String teacher; // 负责学生育人导师的名字
private Integer status;//学生状态是否激活1 激活 0 禁用 private Integer status; // 学生的状态1表示激活0表示禁用
// 无参构造函数
public Student() { public Student() {
} }
// 全参构造函数,用于创建具有所有属性的学生对象
public Student(Integer id, String name, String sex, String sno, String stu_class, String phone, String place, String dorm_id, String teacher, Integer status) { public Student(Integer id, String name, String sex, String sno, String stu_class, String phone, String place, String dorm_id, String teacher, Integer status) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -36,6 +36,7 @@ public class Student implements Serializable {
this.status = status; this.status = status;
} }
// Getter和Setter方法用于访问和修改私有属性
public Integer getId() { public Integer getId() {
return id; return id;
} }
@ -116,6 +117,7 @@ public class Student implements Serializable {
this.status = status; this.status = status;
} }
// toString方法用于返回对象的字符串表示形式便于调试和日志记录
@Override @Override
public String toString() { public String toString() {
return "Student{" + return "Student{" +

@ -6,31 +6,93 @@ import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
* Description: * Description:
*
* @Date: 2020/2/17 14:21
* @Author: PeiChen
*/ */
public interface StudentService { public interface StudentService {
List<Student> findAll(int page,int size) throws Exception; /**
*
* @param page
* @param size
* @return
* @throws Exception
*/
List<Student> findAll(int page, int size) throws Exception;
/**
*
* @param sno
* @return
* @throws Exception
*/
Student findBySno(String sno) throws Exception; Student findBySno(String sno) throws Exception;
/**
*
* @param page
* @param size
* @param keyword
* @return
* @throws Exception
*/
List<Student> search(int page, int size, String keyword) throws Exception; List<Student> search(int page, int size, String keyword) throws Exception;
/**
*
* @param student
* @return truefalse
* @throws Exception
*/
boolean add(Student student) throws Exception; boolean add(Student student) throws Exception;
/**
*
* @param sno
* @throws Exception
*/
void delete(String sno) throws Exception; void delete(String sno) throws Exception;
/**
*
* @param student
* @throws Exception
*/
void update(Student student) throws Exception; void update(Student student) throws Exception;
//返回一个携带所有学生信息数据的InputStream输入流 /**
*
* @return InputStream
* @throws Exception
*/
InputStream getInputStream() throws Exception; InputStream getInputStream() throws Exception;
List<Student> findByDormId(String dorm_id,Integer status) throws Exception; /**
* 宿ID
* @param dorm_id 宿ID
* @param status
* @return
* @throws Exception
*/
List<Student> findByDormId(String dorm_id, Integer status) throws Exception;
List<Student> findByTeacher(int page,int size,String teacher) throws Exception; /**
*
* @param page
* @param size
* @param teacher
* @return
* @throws Exception
*/
List<Student> findByTeacher(int page, int size, String teacher) throws Exception;
List<Student> searchStudent(int page,int size,String teacher,String keyword) throws Exception; /**
*
* @param page
* @param size
* @param teacher
* @param keyword
* @return
* @throws Exception
*/
List<Student> searchStudent(int page, int size, String teacher, String keyword) throws Exception;
} }

@ -1,33 +1,19 @@
<%--
Created by IntelliJ IDEA.
User: user
Date: 2020/2/17
Time: 12:33
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<head> <head>
<title>Title</title> <title>Title</title>
<!-- 引入Bootstrap样式表 -->
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.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 type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/layer/layer.js"></script>
</head> </head>
<body> <body>
<form> <form>
<!-- 创建一个表格,用于输入学生信息 -->
<table class="table" style="width: 100%;text-align: center;"> <table class="table" style="width: 100%;text-align: center;">
<tbody> <tbody>
<tr> <tr>
<td> <td><label for="name">姓名</label></td>
<label for="name">姓名</label> <td><input type="text" class="form-control" id="name" name="name" maxlength="10" required></td>
</td> <td><label for="sex">性别</label></td>
<td>
<input type="text" class="form-control" id="name" name="name" maxlength="10" required>
</td>
<td>
<label for="sex">性别</label>
</td>
<td> <td>
<select class="form-control" name="sex" id="sex"> <select class="form-control" name="sex" id="sex">
<option value="男" selected>男</option> <option value="男" selected>男</option>
@ -36,28 +22,16 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td><label for="sno">学号</label></td>
<label for="sno">学号</label> <td><input type="text" name="sno" class="form-control" id="sno" aria-describedby="textHelp" maxlength="20" required></td>
</td> <td><label for="stu_class">班级</label></td>
<td> <td><input type="text" name="stu_class" class="form-control" id="stu_class" maxlength="30" required></td>
<input type="text" name="sno" class="form-control" id="sno" aria-describedby="textHelp" maxlength="20" required>
</td>
<td>
<label for="stu_class">班级</label>
</td>
<td>
<input type="text" name="stu_class" class="form-control" id="stu_class" maxlength="30" required>
</td>
</tr> </tr>
<tr> <tr>
<td><label for="phone">联系方式</label></td> <td><label for="phone">联系方式</label></td>
<td> <td><input type="text" name="phone" class="form-control" id="phone" minlength="11" maxlength="11" required></td>
<input type="text" name="phone" class="form-control" id="phone" minlength="11" maxlength="11" required>
</td>
<td><label for="place">家庭住址</label></td> <td><label for="place">家庭住址</label></td>
<td> <td><input type="text" placeholder="请输入家庭详细地址" name="place" class="form-control" id="place" maxlength="30" required></td>
<input type="text" placeholder="请输入家庭详细地址" name="place" class="form-control" id="place" maxlength="30" required>
</td>
</tr> </tr>
<tr> <tr>
<td><label for="dorm1">宿舍号</label></td> <td><label for="dorm1">宿舍号</label></td>
@ -73,49 +47,45 @@
<option value="A" selected>A</option> <option value="A" selected>A</option>
<option value="B">B</option> <option value="B">B</option>
</select></td> </select></td>
<td> <td><input type="text" name="dorm3" placeholder="请直接输入宿舍号" maxlength="3" class="form-control" id="dorm3" required></td>
<input type="text" name="dorm3" placeholder="请直接输入宿舍号" maxlength="3" class="form-control" id="dorm3" required>
</td>
</tr> </tr>
<tr> <tr>
<td><label for="teacher">育人导师</label></td> <td><label for="teacher">育人导师</label></td>
<td> <td><select class="form-control" name="teacher" id="teacher">
<select class="form-control" name="teacher" id="teacher"> <option value="小李" selected>小李</option>
<option value="小李" selected>小李</option> <option value="小王">小王</option>
<option value="小王">小王</option> <option value="小赵">小赵</option>
<option value="小赵">小赵</option> <option value="小飞">小飞</option>
<option value="小飞">小飞</option> <option value="小张">小张</option>
<option value="小张">小张</option> </select></td>
</select>
</td>
<td><label for="status">状态</label></td> <td><label for="status">状态</label></td>
<td> <td><select class="form-control" name="status" id="status">
<select class="form-control" name="status" id="status"> <option value="0" selected>禁用</option>
<option value="0" selected>禁用</option> <option value="1">激活</option>
<option value="1">激活</option> </select></td>
</select>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="4"> <td colspan="4">
<!-- 确认添加按钮 -->
<button type="button" id="add-student" class="btn btn-primary">确认添加</button> <button type="button" id="add-student" class="btn btn-primary">确认添加</button>
<a href="javascript:window.history.back(-1)" target="_self" class="btn btn-default">返回列表</a> <!-- 返回列表链接 -->
<a href="window.history.back(-1)" target="_self" class="btn btn-default">返回列表</a>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</form> </form>
<!-- jQuery脚本 -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script> <script>
$(function () { $(function () {
//ajax校验学号已被注册 // ajax校验学号已被注册
$("#sno").change(function () { $("#sno").change(function () {
//取sno的值 var sno = $(this).val(); // 获取学号的值
var sno = $(this).val();
//ajax异步请求
$.get("${pageContext.request.contextPath}/student/isExist",{"sno":sno},function (date) { $.get("${pageContext.request.contextPath}/student/isExist",{"sno":sno},function (date) {
//$(".error").html(msg);
if (date) { if (date) {
layer.msg('学号已被注册,请重新输入!'); layer.msg('学号已被注册,请重新输入!'); // 提示学号已被注册
return false; return false;
} }
}); });
@ -133,21 +103,18 @@
var status = $("#status").val().trim(); var status = $("#status").val().trim();
if (name == 0 || sex == 0 || sno == 0 || stu_class == 0 || phone == 0 || place == 0 || dorm3 == 0 || teacher == 0) { if (name == 0 || sex == 0 || sno == 0 || stu_class == 0 || phone == 0 || place == 0 || dorm3 == 0 || teacher == 0) {
layer.msg('字段不能为空'); layer.msg('字段不能为空'); // 提示字段不能为空
return false; return false;
} }
if (${sessionScope.adminInfo.power < 1}) { if (${sessionScope.adminInfo.power < 1}) {
layer.msg('对不起,您权限不足'); layer.msg('对不起,您权限不足'); // 提示权限不足
return false; return false;
} }
var d1 = $("#dorm1").val(); var d1 = $("#dorm1").val();
var d2 = $("#dorm2").val(); var d2 = $("#dorm2").val();
var dorm_id = d1+""+d2+""+dorm3; var dorm_id = d1+""+d2+""+dorm3; // 拼接宿舍ID
//alert(dorm_id);
$.ajax({ $.ajax({
url: "${pageContext.request.contextPath}/student/add",//要请求的服务器url url: "${pageContext.request.contextPath}/student/add", // 请求的URL
//这是一个对象表示请求的参数两个参数method=ajax&val=xxx服务器可以通过request.getParameter()来获取
//data:{method:"ajaxTest",val:value},
data: { data: {
name:name, name:name,
sex:sex, sex:sex,
@ -159,33 +126,33 @@
teacher:teacher, teacher:teacher,
status:status status:status
}, },
type: "POST", //请求方式为POST type: "POST", // 请求方式为POST
dataType: "json", dataType: "json", // 数据类型为JSON
success:function(result){ //这个方法会在服务器执行成功时被调用 参数data就是服务器返回的值(现在是json类型) success:function(result){ // 成功回调函数
//alert(result);
if(result){ if(result){
layer.msg('添加成功!'); layer.msg('添加成功!'); // 提示添加成功
if (${sessionScope.adminInfo.power == 1}) { if (${sessionScope.adminInfo.power == 1}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';},2000); setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';},2000); // 跳转到宿舍管理员页面
return false; return false;
} }
if (${sessionScope.adminInfo.power == 2}) { if (${sessionScope.adminInfo.power == 2}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';},2000); setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';},2000); // 跳转到学生查询页面
return flase; return false;
} }
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/student/findAll';},2000); setTimeout(function () {window.location.href='${pageContext.request.contextPath}/student/findAll';},2000);
}else { }else {
layer.msg('添加失败,请联系管理员'); layer.msg('添加失败,请联系管理员'); // 如果操作失败,显示错误消息
if (${sessionScope.adminInfo.power == 1}) { if (${sessionScope.adminInfo.power == 1}) { // 根据用户权限不同,跳转到不同的页面
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';},2000); // 宿舍管理员权限2秒后跳转到宿舍管理员页面
setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';}, 2000);
return false; return false;
} }
if (${sessionScope.adminInfo.power == 2}) { if (${sessionScope.adminInfo.power == 2}) { // 学生权限2秒后跳转到学生查询页面
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';}, 2000);
return flase; return false; //
} }
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/student/findAll';},2000); // 默认情况下2秒后跳转到学生列表页面
} setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/student/findAll';}, 2000);}
} }
}); });
}); });

@ -1,11 +1,4 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: user
Date: 2020/2/17
Time: 12:34
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html> <html>
<head> <head>
@ -159,44 +152,44 @@
//这是一个对象表示请求的参数两个参数method=ajax&val=xxx服务器可以通过request.getParameter()来获取 //这是一个对象表示请求的参数两个参数method=ajax&val=xxx服务器可以通过request.getParameter()来获取
//data:{method:"ajaxTest",val:value}, //data:{method:"ajaxTest",val:value},
data: { data: {
id:id, id: id,
name:name, name: name,
sex:sex, sex: sex,
sno: sno, sno: sno,
stu_class:stu_class, stu_class: stu_class,
phone: phone, phone: phone,
place: place, place: place,
dorm_id:dorm_id, dorm_id: dorm_id,
teacher:teacher, teacher: teacher,
status:status status: status
}, },
type: "POST", //请求方式为POST type: "POST", // 请求方式为POST
dataType: "json", dataType: "json", // 期望从服务器接收的数据类型为JSON
success:function(result){ //这个方法会在服务器执行成功时被调用 参数data就是服务器返回的值(现在是json类型) success: function(result) { // 成功回调函数参数result是服务器返回的数据
//alert(result); if (result) {
if(result){ layer.msg('修改成功'); // 显示修改成功的提示消息
layer.msg('修改成功'); // 根据用户权限重定向到不同的页面
if (${sessionScope.adminInfo.power == 1}) { if (${sessionScope.adminInfo.power == 1}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';}, 2000);
return false; return false;
} }
if (${sessionScope.adminInfo.power == 2}) { if (${sessionScope.adminInfo.power == 2}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';}, 2000);
return flase; return false; // 注意这里应该是 return false; 而不是 return flase;
} }
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/student/findAll';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/student/findAll';}, 2000);
}else { } else {
layer.msg('修改失败,请联系管理员'); layer.msg('修改失败,请联系管理员'); // 显示修改失败的提示消息
// 根据用户权限重定向到不同的页面
if (${sessionScope.adminInfo.power == 1}) { if (${sessionScope.adminInfo.power == 1}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/byDorm_leader?uid=${sessionScope.adminInfo.uid}';}, 2000);
return false; return false;
} }
if (${sessionScope.adminInfo.power == 2}) { if (${sessionScope.adminInfo.power == 2}) {
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/dorm/findStudent?name=${sessionScope.adminInfo.name}';}, 2000);
return flase; return false; // 注意这里应该是 return false; 而不是 return flase;
} }
setTimeout(function () {window.location.href='${pageContext.request.contextPath}/student/findAll';},2000); setTimeout(function () {window.location.href = '${pageContext.request.contextPath}/student/findAll';}, 2000);}
}
} }
}); });
}); });

@ -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" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html class="x-admin-sm"> <html class="x-admin-sm">
@ -13,36 +6,37 @@
<title></title> <title></title>
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <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/font.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css"> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.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]--> <![endif]-->
<script>
<script type="text/javascript">
// 定义一个函数用于改变每页显示条数
function changePageSize() { function changePageSize() {
//获取下拉框的值 // 获取下拉框的值
var pageSize = $("#changePageSize").val(); var pageSize = $("#changePageSize").val();
//向服务器发送请求,改变每页显示条数 // 向服务器发送请求,改变每页显示条数
location.href = "${pageContext.request.contextPath}/student/findAll?page=1&size="+ pageSize; location.href = "${pageContext.request.contextPath}/student/findAll?page=1&size=" + pageSize;
} }
// 绑定搜索按钮点击事件
$("#serarch_btn").click(function () { $("#serarch_btn").click(function () {
var keyword = $("#keyword").val(); var keyword = $("#keyword").val(); // 获取输入框中的关键字
location.href="${pageContext.request.contextPath}/student/findAll?page=1&size=5&keyword="+keyword; location.href = "${pageContext.request.contextPath}/student/findAll?page=1&size=5&keyword=" + keyword; // 向服务器发送请求,根据关键字搜索
}); });
// 绑定刷新按钮点击事件
$("#refresh").click(function () { $("#refresh").click(function () {
$("#myform").reset(); $("#myform").reset(); // 重置表单
location.href="${pageContext.request.contextPath}/student/findAll?page=1&size=5"; location.href = "${pageContext.request.contextPath}/student/findAll?page=1&size=5"; // 重新加载页面
}); });
</script> </script>
</head> </head>
<body> <body>
<%-- 导航栏部分被注释掉了 --%>
<%--<div class="x-nav"> <%--<div class="x-nav">
<span class="layui-breadcrumb"> <span class="layui-breadcrumb">
<a href="">首页</a> <a href="">首页</a>
@ -50,7 +44,7 @@
<a> <a>
<cite>导航元素</cite></a> <cite>导航元素</cite></a>
</span> </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> <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>--%> </div>--%>
<div class="layui-fluid"> <div class="layui-fluid">
@ -58,24 +52,29 @@
<div class="layui-col-md12"> <div class="layui-col-md12">
<div class="layui-card"> <div class="layui-card">
<div class="layui-card-body "> <div class="layui-card-body ">
<!-- 搜索表单 -->
<form id="myform" class="layui-form layui-col-space5"> <form id="myform" class="layui-form layui-col-space5">
<div class="layui-inline layui-show-xs-block"> <div class="layui-inline layui-show-xs-block">
<input class="layui-input" type="text" autocomplete="off" placeholder="请输入关键字" name="keyword" id="keyword" value="${param.keyword}"> <input class="layui-input" type="text" autocomplete="off" placeholder="请输入关键字" name="keyword" id="keyword" value="${param.keyword}">
</div> </div>
<div class="layui-inline layui-show-xs-block"> <div class="layui-inline layui-show-xs-block">
<button class="layui-btn" id="serarch_btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button> <button class="layui-btn" id="serarch_btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
</div> </div>
<div class="layui-inline layui-show-xs-block x-right"> <div class="layui-inline layui-show-xs-block x-right">
<a class="layui-btn layui-btn-normal" href="${pageContext.request.contextPath}/student/findAll?page=1&size=5"><i class="layui-icon">&#xe669;</i></a> <a class="layui-btn layui-btn-normal" href="${pageContext.request.contextPath}/student/findAll?page=1&size=5"><i class="layui-icon">&#xe669;</i>全部</a>
</div> </div>
</form> </form>
</div> </div>
<xblock> <xblock>
<!-- 添加学生按钮 -->
<a href="${pageContext.request.contextPath}/student/addStudent" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe654;</i>添加</a> <a href="${pageContext.request.contextPath}/student/addStudent" class="layui-btn layui-btn-normal"><i class="layui-icon">&#xe654;</i>添加</a>
<a onclick="exportInfo()" class="layui-btn layui-btn-warm" href="javascript:;"><i class="layui-icon">&#xe67c;</i>导出</a> <!-- 导出信息按钮(功能未实现) -->
<a "exportInfo()" class="layui-btn layui-btn-warm" href=";"><i class="layui-icon">&#xe67c;</i>导出</a>
<!-- 显示数据总数 -->
<span class="x-right" style="line-height:40px">共有数据:${pageInfo.total} 条</span> <span class="x-right" style="line-height:40px">共有数据:${pageInfo.total} 条</span>
</xblock> </xblock>
<div class="layui-card-body"> <div class="layui-card-body">
<!-- 表格展示学生信息 -->
<table class="layui-table layui-form"> <table class="layui-table layui-form">
<thead> <thead>
<tr style="text-align: center"> <tr style="text-align: center">
@ -94,38 +93,44 @@
</thead> </thead>
<tbody> <tbody>
<% <%
int j = 1; int j = 1; // 初始化行号计数器
%> %>
<!-- 遍历学生列表并生成表格行 -->
<c:forEach items="${pageInfo.list}" var="student"> <c:forEach items="${pageInfo.list}" var="student">
<tr id="light" style="text-align: center"> <tr id="light" style="text-align: center">
<td><%=j++%></td> <td><%=j++%></td> <!-- 显示行号 -->
<td>${student.name}</td> <td>${student.name}</td> <!-- 显示学生姓名 -->
<td>${student.sex}</td> <td>${student.sex}</td> <!-- 显示学生性别 -->
<td>${student.sno}</td> <td>${student.sno}</td> <!-- 显示学生学号 -->
<td>${student.stu_class}</td> <td>${student.stu_class}</td> <!-- 显示学生班级 -->
<td>${student.phone}</td> <td>${student.phone}</td> <!-- 显示学生联系方式 -->
<td>${student.dorm_id}</td> <td>${student.dorm_id}</td> <!-- 显示学生宿舍号 -->
<td>${student.teacher}</td> <td>${student.teacher}</td> <!-- 显示学生育人导师 -->
<c:if test="${student.status == 1}"> <c:if test="${student.status == 1}">
<td><button class="layui-btn layui-btn-normal layui-btn-sm">已激活</button></td> <!-- 显示已激活状态 -->
</c:if> <td><button class="layui-btn layui-btn-normal layui-btn-sm">已激活</button></td>
<c:if test="${student.status == 0}"> </c:if>
<td><button class="layui-btn layui-btn-danger layui-btn-sm">禁用</button></td> <c:if test="${student.status == 0}">
</c:if> <!-- 显示禁用状态 -->
<c:if test="${sessionScope.adminInfo.power > 1}"> <td><button class="layui-btn layui-btn-danger layui-btn-sm">禁用</button></td>
<td class="td-manage"> </c:if>
<a title="编辑" href="${pageContext.request.contextPath}/student/editStudent?sno=${student.sno}"> <c:if test="${sessionScope.adminInfo.power > 1}">
<i class="layui-icon">&#xe642;</i> <td class="td-manage">
</a> <!-- 编辑按钮 -->
<a title="删除" onclick="member_del(this,${student.sno},${sessionScope.adminInfo.power})" href="javascript:;"> <a title="编辑" href="${pageContext.request.contextPath}/student/editStudent?sno=${student.sno}">
<i class="layui-icon">&#xe640;</i> <i class="layui-icon">&#xe642;</i>
</a> </a>
</td> <!-- 删除按钮(功能未实现) -->
</c:if> <a title="删除" href=";" onclick="member_del(this,${student.sno},${sessionScope.adminInfo.power})">
</c:forEach> <i class="layui-icon">&#xe640;</i>
</tr> </a>
</td>
</c:if>
</tr>
</c:forEach>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="pull-left"> <div class="pull-left">
<div class="form-group form-inline"> <div class="form-group form-inline">
@ -139,32 +144,28 @@
</select> 条 </select> 条
</div> </div>
</div> </div>
// 根据总页数和当前页码,动态设置分页导航的起始和结束页码
<c:choose> <c:choose>
<c:when test="${pageInfo.pages < 5}"> <c:when test="${pageInfo.pages < 5}">
<c:set var="begin" value="1"> <c:set var="begin" value="1"/>
</c:set> <c:set var="end" value="${pageInfo.pages}"/>
<c:set var="end" value="${pageInfo.pages}">
</c:set>
</c:when> </c:when>
<c:when test="${pageInfo.pageNum <= 3}"> <c:when test="${pageInfo.pageNum <= 3}">
<c:set var="begin" value="1"> <c:set var="begin" value="1"/>
</c:set> <c:set var="end" value="5"/>
<c:set var="end" value="5">
</c:set>
</c:when> </c:when>
<c:when test="${pageInfo.pageNum > 3 and pageInfo.pageNum <= pageInfo.pages-2}"> <c:when test="${pageInfo.pageNum > 3 and pageInfo.pageNum <= pageInfo.pages-2}">
<c:set var="begin" value="${pageInfo.pageNum - 2}"> <c:set var="begin" value="${pageInfo.pageNum - 2}"/>
</c:set> <c:set var="end" value="${pageInfo.pageNum + 2}"/>
<c:set var="end" value="${pageInfo.pageNum + 2}">
</c:set>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<c:set var="begin" value="${pageInfo.pages - 4}"> <c:set var="begin" value="${pageInfo.pages - 4}"/>
</c:set> <c:set var="end" value="${pageInfo.pages}"/>
<c:set var="end" value="${pageInfo.pages}">
</c:set>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
// 分页导航按钮部分
<div class="layui-card-body x-right" style="height: min-content"> <div class="layui-card-body x-right" style="height: min-content">
<div class="page"> <div class="page">
<div> <div>
@ -183,8 +184,7 @@
<c:if test="${pageInfo.pageNum < pageInfo.pages}"> <c:if test="${pageInfo.pageNum < pageInfo.pages}">
<a class="next" href="${pageContext.request.contextPath}/student/findAll?page=${pageInfo.pageNum+1}&size=${pageInfo.pageSize}&keyword=${param.keyword}">下一页</a> <a class="next" href="${pageContext.request.contextPath}/student/findAll?page=${pageInfo.pageNum+1}&size=${pageInfo.pageSize}&keyword=${param.keyword}">下一页</a>
</c:if> </c:if>
<a class="next" href="${pageContext.request.contextPath}/student/findAll?page=${pageInfo.pages}&size=${pageInfo.pageSize}&keyword=${param.keyword}">尾页</a> <a class="next" href="${pageContext.request.contextPath}/student/findAll?page=${pageInfo.pages}&size=${pageInfo.pageSize}&keyword=${param.keyword}">尾页</a></div>
</div>
</div> </div>
</div> </div>
</div> </div>

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

Loading…
Cancel
Save