update CourseQuery

Signed-off-by: Chenx221 <chenx221@yandex.com>
This commit is contained in:
Chenx221 2023-06-10 13:53:25 +08:00
parent 19049f907e
commit 9c50926a51
21 changed files with 1320 additions and 7 deletions

View File

@ -3,8 +3,11 @@
<component name="WebContextManager">
<option name="state">
<map>
<entry key="file://$PROJECT_DIR$/web/WEB-INF/views/courseList.jsp" value="file://$PROJECT_DIR$/web/WEB-INF/views" />
<entry key="file://$PROJECT_DIR$/web/WEB-INF/views/courseopv2.jsp" value="file://$PROJECT_DIR$/web/WEB-INF/views" />
<entry key="file://$PROJECT_DIR$/web/WEB-INF/views/studentInfoAdd.jsp" value="file://$PROJECT_DIR$/web/WEB-INF/views" />
<entry key="file://$PROJECT_DIR$/web/WEB-INF/views/studentList.jsp" value="file://$PROJECT_DIR$/web/WEB-INF/views" />
<entry key="file://$PROJECT_DIR$/web/WEB-INF/views/studentinfomodv2.jsp" value="file://$PROJECT_DIR$/web/WEB-INF/views" />
</map>
</option>
</component>

View File

@ -8,4 +8,19 @@
FROM course
WHERE removed = 0
</select>
<select id="getQueryCourses" resultType="cyou.chenx221.pojo.Course" parameterType="cyou.chenx221.pojo.Course">
SELECT *
FROM course
WHERE 1=1 AND removed = 0
<if test="courseID != null">
AND CourseID = #{courseID}
</if>
<if test="courseName != null">
AND CourseName LIKE CONCAT('%', #{courseName}, '%')
</if>
<if test="description != null">
AND Description LIKE CONCAT('%', #{description}, '%')
</if>
</select>
</mapper>

View File

@ -0,0 +1,172 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>课程信息查询结果页</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 80vw; /* 设置最小宽度为视窗宽度的80% */
min-height: 80vh; /* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px;">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">课程描述</th>
</tr>
</thead>
<tbody>
<c:forEach var="course" items="${courses}">
<tr>
<td>${course.courseID}</td>
<td>${course.courseName}</td>
<td>${course.description}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,405 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>课程信息修改v2</title>
<script src="${pageContext.request.contextPath}/resources/js/jquery-3.7.0.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 60vw;
/* 设置最小宽度为视窗宽度的80% */
min-height: 80vh;
/* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">课程描述</th>
</tr>
</thead>
<tbody>
<c:forEach var="course" items="${courses}">
<tr>
<td>${course.courseID}</td>
<td>${course.courseName}</td>
<td>${course.description}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<div class="container">
<div class="card rounded-4 shadow-3-strong" style="min-width: 244px">
<!-- Tabs navs -->
<ul class="nav nav-tabs" id="ex1" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active fs-6" id="ex1-tab-1" data-mdb-toggle="tab" href="#ex1-tabs-1"
role="tab" aria-controls="ex1-tabs-1" aria-selected="true">信息查询</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-2" data-mdb-toggle="tab" href="#ex1-tabs-2"
role="tab" aria-controls="ex1-tabs-2" aria-selected="true">信息修改</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-3" data-mdb-toggle="tab" href="#ex1-tabs-3"
role="tab" aria-controls="ex1-tabs-3" aria-selected="false">信息删除</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-4" data-mdb-toggle="tab" href="#ex1-tabs-4"
role="tab" aria-controls="ex1-tabs-4" aria-selected="false">信息添加</a>
</li>
</ul>
<!-- Tabs navs -->
<hr class="hr" style="margin: 1px"/>
<!-- Tabs content -->
<div class="tab-content" id="ex1-content">
<div class="tab-pane fade show active" id="ex1-tabs-1" role="tabpanel"
aria-labelledby="ex1-tab-1">
<div class="card-body" style="min-width: 175px">
<form action="query" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText1" class="form-control"
name="id"/>
<label class="form-label" for="typeText1">课程ID</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText2" class="form-control"
name="name"/>
<label class="form-label" for="typeText2">课程名(支持部分关键词匹配)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText3" class="form-control"
name="description"/>
<label class="form-label" for="typeText3">描述(支持部分关键词匹配)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">查询
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel"
aria-labelledby="ex1-tab-2">
<div class="card-body" style="min-width: 175px">
<form action="modinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText7" class="form-control"
required name="id"/>
<label class="form-label" for="typeText7">课程ID (必填)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText8" class="form-control"
name="name"/>
<label class="form-label" for="typeText8">课程名</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText9" class="form-control"
name="description"/>
<label class="form-label" for="typeText9">课程描述</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary"
data-mdb-toggle="tooltip" data-mdb-placement="top"
title="留空为不做修改">更改
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
<div class="card-body" style="min-width: 175px">
<form action="delinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText13" class="form-control"
required name="id"/>
<label class="form-label" for="typeText13">课程ID (必填)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">删除</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-4" role="tabpanel" aria-labelledby="ex1-tab-4">
<!-- <h5 class="card-header">信息添加</h5> -->
<div class="card-body" style="min-width: 175px">
<form action="addinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText14" class="form-control"
name="name"/>
<label class="form-label" for="typeText14">课程名 (必填)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText15" class="form-control"
name="description"/>
<label class="form-label" for="typeText15">课程描述 (必填)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">添加
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Tabs content -->
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
<i class="fas fa-circle-exclamation me-2"></i>错误
</h5>
<button type="button" class="btn-close" data-mdb-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<c:if test="${not empty errorMessage}">
${errorMessage}
</c:if>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-mdb-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal2" tabindex="-1" aria-labelledby="exampleModalLabel2"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">
<i class="fas fa-circle-check me-2"></i>成功
</h5>
<button type="button" class="btn-close" data-mdb-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<c:if test="${not empty successMessage}">
${successMessage}
</c:if>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-mdb-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
<script>
$(document).ready(function () {
// 判断模型中是否存在错误信息
<c:if test="${not empty errorMessage && errorMessage ne 'null'}">
$('#exampleModal').modal('show');
</c:if>
<c:if test="${not empty successMessage && successMessage ne 'null'}">
$('#exampleModal2').modal('show');
</c:if>
});
</script>
</body>
</html>

View File

@ -54,8 +54,8 @@
<li>
<hr class="dropdown-divider" />
</li>
<li><a class="dropdown-item" href="course/all">课程管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="course/all">课程查看</a></li>
<li><a class="dropdown-item" href="course/infomodv2">课程管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>

View File

@ -403,7 +403,7 @@
<!-- Footer -->
<script type="text/javascript" src="../../resources/js/mdb.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
<script>
$(document).ready(function () {
// 判断模型中是否存在错误信息

View File

@ -6,8 +6,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.sql.Date;
import java.util.List;
@Controller
@ -26,4 +29,111 @@ public class CourseController {
model.addAttribute("courses", courses);
return "courseList"; // 重定向到 dashboard 页面
}
@GetMapping("/infomodv2")//处理学生信息修改页
public String getInfoModv2(@RequestParam(value = "successMessage", required = false, defaultValue = "null") String successMessage,
@RequestParam(value = "errorMessage", required = false, defaultValue = "null") String errorMessage,
Model model) {
List<Course> courses = courseService.getAllCourses();
model.addAttribute("courses", courses);
// 将消息添加到Model中
model.addAttribute("successMessage", successMessage);
model.addAttribute("errorMessage", errorMessage);
return "courseopv2";
}
// @PostMapping(value = "/delinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
// public String UpdateModInfo(@RequestParam(value = "id") int id,
// Model model) {
// Student temp = studentService.getStudentById(id);
// if (id <= 0 || temp == null) {
// model.addAttribute("errorMessage", "学生信息删除失败,可能是ID非法或者学生已删除");
// } else {
//// Student student = new Student(id);
// studentService.deleteStudent(id);
// model.addAttribute("successMessage", "学生信息删除成功");
// }
// return "redirect:/student/infomodv2";
// }
//
// @PostMapping(value = "/addinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
// public String InsertStudentInfo(@RequestParam(value = "name") String name,
// @RequestParam(value = "birthday") Date birthday,
// @RequestParam(value = "sex") String sex,
// @RequestParam(value = "phone") String phone,
// @RequestParam(value = "classes") String classes,
// Model model) {
// Student student;
// String classesPattern = "[1-5]班";// 使用正则表达式验证班级格式
//
// //格式合法性检查
// if (!sex.equals("") && !sex.equals("")) {
// model.addAttribute("errorMessage", "性别格式不正确,仅允许'男'或'女'");
// } else if (!classes.matches(classesPattern)) {
// model.addAttribute("errorMessage", "班级格式不正确,格式应为?班(?为1~5之间的数字");
// } else {
// student = new Student(name, sex, birthday, phone, classes);
// studentService.insertStudent(student);
// model.addAttribute("successMessage", "学生信息添加成功");
// }
// return "redirect:/student/infomodv2";
// }
//
// @PostMapping(value = "/modinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")//处理学生信息修改请求
// public String UpdateModInfo(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
// @RequestParam(value = "birthday", defaultValue = "null", required = false) String birthdayStr,
// @RequestParam(value = "sex", defaultValue = "null", required = false) String sex,
// @RequestParam(value = "id", defaultValue = "-1", required = false) int id,
// @RequestParam(value = "phone", defaultValue = "null", required = false) String phone,
// @RequestParam(value = "classes", defaultValue = "", required = false) String classes,
// Model model) {
// Date birthday = null;
// if (!"null".equals(birthdayStr)) {
// birthday = Date.valueOf(birthdayStr);
// }
// System.out.println(birthday);//debug
// Student student;
// if (name.equals("null")) name = null;
// if (sex.equals("null")) sex = null;
// if (phone.equals("null")) phone = null;
// if (classes.equals("")) classes = null;
//
// if (id <= -1) {
// model.addAttribute("errorMessage", "学生信息修改失败");
// } else {
// student = new Student(id, name, sex, birthday, phone, classes);
// studentService.updateStudent(student);
// model.addAttribute("successMessage", "学生信息修改成功");
// }
// return "redirect:/student/infomodv2";
// }
@PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询带条件
public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
@RequestParam(value = "description", defaultValue = "null", required = false) String description,
@RequestParam(value = "id", defaultValue = "-1", required = false) int id,
Model model) {
if (name.equals("null")) name = null;
if (description.equals("null")) description = null;
if (name == null && description == null && id <= 0) {
model.addAttribute("errorMessage", "查询条件不可全为空");
return "redirect:/course/infomodv2";
}
List<Course> courses;
Course course;
course = new Course((id == -1 ? null : id), name, description);
System.out.println("id:" + id + " name:" + name + " description:" + description);
// if(course.getCourseID() == null){
// System.out.println("WARNNING : id is null");
// }
// if (course.getCourseName() == null) {
// System.out.println("WARNNING : courseName is null");
// }
// if (course.getDescription() == null) {
// System.out.println("WARNNING : description is null");
// }
courses = courseService.getQueryCourses(course);
model.addAttribute("courses", courses);
return "courseQueryResult";
}
}

View File

@ -8,4 +8,6 @@ import java.util.List;
@Repository
public interface CourseDao {
List<Course> getAllCourses();
List<Course> getQueryCourses(Course course);
}

View File

@ -20,4 +20,9 @@ public class CourseDaoImpl implements CourseDao {
public List<Course> getAllCourses() {
return sqlSession.selectList("getAllCourses");
}
@Override
public List<Course> getQueryCourses(Course course) {
return sqlSession.selectList("getQueryCourses", course);
}
}

View File

@ -10,6 +10,12 @@ public class Course {
Description = description;
}
public Course(Integer courseID, String courseName, String description) {
CourseID = courseID;
CourseName = courseName;
Description = description;
}
public Course() {
}

View File

@ -1,7 +1,6 @@
package cyou.chenx221.service;
import cyou.chenx221.mapper.CourseDao;
import cyou.chenx221.mapper.StudentDao;
import cyou.chenx221.pojo.Course;
import org.springframework.stereotype.Service;
@ -19,4 +18,8 @@ public class CourseService {
public List<Course> getAllCourses() {
return courseDao.getAllCourses();
}
public List<Course> getQueryCourses(Course course) {
return courseDao.getQueryCourses(course);
}
}

View File

@ -8,4 +8,19 @@
FROM course
WHERE removed = 0
</select>
<select id="getQueryCourses" resultType="cyou.chenx221.pojo.Course" parameterType="cyou.chenx221.pojo.Course">
SELECT *
FROM course
WHERE 1=1 AND removed = 0
<if test="courseID != null">
AND CourseID = #{courseID}
</if>
<if test="courseName != null">
AND CourseName LIKE CONCAT('%', #{courseName}, '%')
</if>
<if test="description != null">
AND Description LIKE CONCAT('%', #{description}, '%')
</if>
</select>
</mapper>

View File

@ -0,0 +1,172 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>课程信息查询结果页</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 80vw; /* 设置最小宽度为视窗宽度的80% */
min-height: 80vh; /* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px;">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">课程描述</th>
</tr>
</thead>
<tbody>
<c:forEach var="course" items="${courses}">
<tr>
<td>${course.courseID}</td>
<td>${course.courseName}</td>
<td>${course.description}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,405 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
<title>课程信息修改v2</title>
<script src="${pageContext.request.contextPath}/resources/js/jquery-3.7.0.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700;900&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/mdb.min.css"/>
<style>
.table-container {
min-width: 60vw;
/* 设置最小宽度为视窗宽度的80% */
min-height: 80vh;
/* 设置最小高度为视窗高度的80% */
/*display: flex;*/
align-items: center;
justify-content: center;
}
.table-container table {
width: 100%;
height: 100%;
}
</style>
</head>
<body style="font-family: 'Noto Sans SC Regular',serif">
<!--Main Navigation-->
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="z-index: 1;min-height: 58.59px">
<div class="container">
<button class="navbar-toggler" type="button" data-mdb-toggle="collapse"
data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand mt-2 mt-lg-0" href="#">
<i class="fas fa-chalkboard-user me-2"></i>
教务管理系统
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">首页</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
学生管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="#">学生信息查询</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li><a class="dropdown-item" href="#">学生信息管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li><a class="dropdown-item" href="#">学生成绩管理</a></li>
<li>
<hr class="dropdown-divider"/>
</li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown2" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
教师管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown2">
<li><a class="dropdown-item" href="#">教师信息管理</a></li>
<li><a class="dropdown-item" href="#">教师课程管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown3" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
课程管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown3">
<li><a class="dropdown-item" href="#">课程信息管理</a></li>
<li><a class="dropdown-item" href="#">课程安排管理</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown4" role="button"
data-mdb-toggle="dropdown" aria-expanded="false">
系统管理
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown4">
<li><a class="dropdown-item" href="#">个人设定</a></li>
<li><a class="dropdown-item" href="#">用户管理</a></li>
<li><a class="dropdown-item" href="#">日志管理</a></li>
<li><a class="dropdown-item" href="#">版本信息</a></li>
</ul>
</li>
</ul>
</div>
<div class="dropdown">
<a class="dropdown-toggle d-flex align-items-center hidden-arrow" href="#"
id="navbarDropdownMenuAvatar" role="button" data-mdb-toggle="dropdown" aria-expanded="false">
<i class="fas fa-circle-user fa-lg"></i>
</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownMenuAvatar">
<li>
<a class="dropdown-item" href="${pageContext.request.contextPath}/logout">登出</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<!--Main Navigation-->
<!--Main layout-->
<main>
<div class="bg-image shadow-2-strong vh-100"
style="background-image: url('${pageContext.request.contextPath}/resources/img/jason-blackeye-nyL-rzwP-Mk-unsplash.jpg'); margin-top: -58.59px;">
<div class="mask d-flex align-items-center h-100" style="background-color: hsla(0, 0%, 100%, 0.5);">
<div class="container d-flex justify-content-center">
<button type="button" class="btn btn-primary" onclick="location.href='../dashboard'">返回</button>
<div class="table-container rounded-4 shadow-3-strong"
style="background-color: rgba(255,255,255,0.9); overflow-y: auto; max-height: 400px">
<table class="table table-striped table-hover border-primary">
<thead>
<tr>
<th scope="col">课程ID</th>
<th scope="col">课程名</th>
<th scope="col">课程描述</th>
</tr>
</thead>
<tbody>
<c:forEach var="course" items="${courses}">
<tr>
<td>${course.courseID}</td>
<td>${course.courseName}</td>
<td>${course.description}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<div class="container">
<div class="card rounded-4 shadow-3-strong" style="min-width: 244px">
<!-- Tabs navs -->
<ul class="nav nav-tabs" id="ex1" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active fs-6" id="ex1-tab-1" data-mdb-toggle="tab" href="#ex1-tabs-1"
role="tab" aria-controls="ex1-tabs-1" aria-selected="true">信息查询</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-2" data-mdb-toggle="tab" href="#ex1-tabs-2"
role="tab" aria-controls="ex1-tabs-2" aria-selected="true">信息修改</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-3" data-mdb-toggle="tab" href="#ex1-tabs-3"
role="tab" aria-controls="ex1-tabs-3" aria-selected="false">信息删除</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link fs-6" id="ex1-tab-4" data-mdb-toggle="tab" href="#ex1-tabs-4"
role="tab" aria-controls="ex1-tabs-4" aria-selected="false">信息添加</a>
</li>
</ul>
<!-- Tabs navs -->
<hr class="hr" style="margin: 1px"/>
<!-- Tabs content -->
<div class="tab-content" id="ex1-content">
<div class="tab-pane fade show active" id="ex1-tabs-1" role="tabpanel"
aria-labelledby="ex1-tab-1">
<div class="card-body" style="min-width: 175px">
<form action="query" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText1" class="form-control"
name="id"/>
<label class="form-label" for="typeText1">课程ID</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText2" class="form-control"
name="name"/>
<label class="form-label" for="typeText2">课程名(支持部分关键词匹配)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText3" class="form-control"
name="description"/>
<label class="form-label" for="typeText3">描述(支持部分关键词匹配)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">查询
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel"
aria-labelledby="ex1-tab-2">
<div class="card-body" style="min-width: 175px">
<form action="modinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText7" class="form-control"
required name="id"/>
<label class="form-label" for="typeText7">课程ID (必填)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText8" class="form-control"
name="name"/>
<label class="form-label" for="typeText8">课程名</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText9" class="form-control"
name="description"/>
<label class="form-label" for="typeText9">课程描述</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary"
data-mdb-toggle="tooltip" data-mdb-placement="top"
title="留空为不做修改">更改
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
<div class="card-body" style="min-width: 175px">
<form action="delinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="number" id="typeText13" class="form-control"
required name="id"/>
<label class="form-label" for="typeText13">课程ID (必填)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">删除</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
<div class="tab-pane fade" id="ex1-tabs-4" role="tabpanel" aria-labelledby="ex1-tab-4">
<!-- <h5 class="card-header">信息添加</h5> -->
<div class="card-body" style="min-width: 175px">
<form action="addinfo" method="post">
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText14" class="form-control"
name="name"/>
<label class="form-label" for="typeText14">课程名 (必填)</label>
</div>
</div>
</div>
<div class="row mb-2">
<div class="col-12">
<div class="form-outline">
<input type="text" id="typeText15" class="form-control"
name="description"/>
<label class="form-label" for="typeText15">课程描述 (必填)</label>
</div>
</div>
</div>
<div class="row mb-2 mt-4">
<div class="col-lg-6 text-center">
<button type="submit" class="btn btn-primary">添加
</button>
</div>
<div class="col-lg-6 text-center">
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Tabs content -->
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
<i class="fas fa-circle-exclamation me-2"></i>错误
</h5>
<button type="button" class="btn-close" data-mdb-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<c:if test="${not empty errorMessage}">
${errorMessage}
</c:if>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-mdb-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal2" tabindex="-1" aria-labelledby="exampleModalLabel2"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel2">
<i class="fas fa-circle-check me-2"></i>成功
</h5>
<button type="button" class="btn-close" data-mdb-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<c:if test="${not empty successMessage}">
${successMessage}
</c:if>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-mdb-dismiss="modal">OK</button>
</div>
</div>
</div>
</div>
</main>
<!--Main layout-->
<!-- Footer -->
<footer class="bg-link text-center text-lg-start ">
</footer>
<!-- Footer -->
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
<script>
$(document).ready(function () {
// 判断模型中是否存在错误信息
<c:if test="${not empty errorMessage && errorMessage ne 'null'}">
$('#exampleModal').modal('show');
</c:if>
<c:if test="${not empty successMessage && successMessage ne 'null'}">
$('#exampleModal2').modal('show');
</c:if>
});
</script>
</body>
</html>

View File

@ -54,8 +54,8 @@
<li>
<hr class="dropdown-divider" />
</li>
<li><a class="dropdown-item" href="course/all">课程管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
<li><a class="dropdown-item" href="course/all">课程查看</a></li>
<li><a class="dropdown-item" href="course/infomodv2">课程管理</a></li>
<li><a class="dropdown-item" href="#">学生选课管理</a></li>
</ul>
</li>

View File

@ -403,7 +403,7 @@
<!-- Footer -->
<script type="text/javascript" src="../../resources/js/mdb.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/mdb.min.js"></script>
<script>
$(document).ready(function () {
// 判断模型中是否存在错误信息