一、系统介绍
1.开发环境
开发工具:IDEA2018
JDK版本:jdk1.8
Mysql版本:8.0.13
2.技术选型
Java+Servlet+Boostrap+Jsp+Mysql
3.系统功能
1.用户注册登录系统;
2.管理员审核用户,查看课程选课情况,开启签到,删除课程,修改密码;
3.教师创建课程,查看成员,开启签到,删除课程,修改密码;
4.学生选择课程,退选课程,修改密码;
4.数据库文件
/* Navicat Premium Data Transfer Source Server : MYSQL Source Server Type : MySQL Source Server Version : 80013 Source Host : localhost:3306 Source Schema : servlet_select_course Target Server Type : MySQL Target Server Version : 80013 File Encoding : 65001 Date: 24/12/2021 16:58:38 */ SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ---------------------------- -- Table structure for tb_courses -- ---------------------------- DROP TABLE IF EXISTS `tb_courses`; CREATE TABLE `tb_courses` ( `course_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `teach_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `day` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `is_signin` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `member_num` int(11) NULL DEFAULT NULL, PRIMARY KEY (`course_id`) USING BTREE, INDEX `C_FK`(`teach_id`) USING BTREE, CONSTRAINT `C_FK` FOREIGN KEY (`teach_id`) REFERENCES `tb_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE = InnoDB AUTO_INCREMENT = 29 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of tb_courses -- ---------------------------- INSERT INTO `tb_courses` VALUES (27, '软件工程', '101', '星期一, 1 - 2 节', 'false', 1); INSERT INTO `tb_courses` VALUES (28, '计算机导论', '104', '星期二, 3 - 4 节', 'false', 0); -- ---------------------------- -- Table structure for tb_join -- ---------------------------- DROP TABLE IF EXISTS `tb_join`; CREATE TABLE `tb_join` ( `course_id` int(11) NULL DEFAULT NULL, `stu_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `checked` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of tb_join -- ---------------------------- INSERT INTO `tb_join` VALUES (27, '1001', 'true'); INSERT INTO `tb_join` VALUES (28, '1001', 'checking'); -- ---------------------------- -- Table structure for tb_signin -- ---------------------------- DROP TABLE IF EXISTS `tb_signin`; CREATE TABLE `tb_signin` ( `signin_id` int(11) NOT NULL AUTO_INCREMENT, `course_id` int(11) NULL DEFAULT NULL, `time` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `signin_num` int(11) NULL DEFAULT NULL, `end_time` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, PRIMARY KEY (`signin_id`) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of tb_signin -- ---------------------------- INSERT INTO `tb_signin` VALUES (24, 27, '2021-12-20 15:15:48', 1, '2021-12-20 15:16:16'); -- ---------------------------- -- Table structure for tb_signin_stu -- ---------------------------- DROP TABLE IF EXISTS `tb_signin_stu`; CREATE TABLE `tb_signin_stu` ( `signin_id` int(11) NULL DEFAULT NULL, `stu_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `state` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of tb_signin_stu -- ---------------------------- INSERT INTO `tb_signin_stu` VALUES (24, '1001', 'true'); -- ---------------------------- -- Table structure for tb_users -- ---------------------------- DROP TABLE IF EXISTS `tb_users`; CREATE TABLE `tb_users` ( `user_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `password` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `name` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `type` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, `checked` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, PRIMARY KEY (`user_id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic; -- ---------------------------- -- Records of tb_users -- ---------------------------- INSERT INTO `tb_users` VALUES ('1001', '123456', '同学1', 'stu', 'true'); INSERT INTO `tb_users` VALUES ('1002', '123456', '同学2', 'stu', 'true'); INSERT INTO `tb_users` VALUES ('101', '123456', '教师1', 'teach', 'true'); INSERT INTO `tb_users` VALUES ('102', '123456', '教师2', 'teach', 'true'); INSERT INTO `tb_users` VALUES ('103', '123456', '教师3', 'teach', 'true'); INSERT INTO `tb_users` VALUES ('104', '123456', '王老师', 'teach', 'true'); INSERT INTO `tb_users` VALUES ('105', '123456', '李老师', 'teach', 'false'); INSERT INTO `tb_users` VALUES ('admin', 'admin', '管理员', 'admin', 'true'); SET FOREIGN_KEY_CHECKS = 1;
二、系统展示
1.登录系统
2.注册系统
3.管理员-首页
4.管理员-管理用户
5.管理员-管理课程
6.管理员-修改密码
7.教师-创建课程
8.教师-我的课程
9.教师-修改密码
10.学生-加入课程
11.学生-我的课程
12.学生-修改密码
三、部分代码
CreateCourseAction
package com.sjsq.servlet; import com.sjsq.bean.Course; import com.sjsq.bean.User; import com.sjsq.dao.CourseDao; import javax.servlet.ServletException; import javax.servlet.annotation.MultipartConfig; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; @WebServlet("/CreateCourseAction") @MultipartConfig public class CreateCourseAction extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { super.doGet(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); resp.setContentType("text/html;charset=utf-8"); PrintWriter out = resp.getWriter(); String courseName = req.getParameter("courseName"); String day = req.getParameter("day"); String courseTime = req.getParameter("courseTime"); String Day = day + ", " + courseTime; User user = (User) req.getSession().getAttribute("User"); String teach_id = user.getId(); Course course = new Course(0, courseName, teach_id, Day, "false", 0); CourseDao courseDao = new CourseDao(); int result = courseDao.Create(course); if (result == 0) { out.println("<script> alert('创建课程失败'); location='teacher_create.jsp'; </script>"); } else if (result == 1) { out.println("<script> alert('创建课程成功'); location='teacher_create.jsp'; </script>"); } else { out.println("<script> alert('上课时间冲突'); location='teacher_create.jsp'; </script>"); } } }