石家庄铁道大学学生选课管理系统(50分)
1、项目需求:
石家庄铁道大学为了提高教务处的工作效率,方便用户之间信息的交流,简化学生选课的流程,使选课管理工作更规范化,系统化,程序化,提高信息处理的速度和准确性,能够及时、准确、有效的查询和修改选课排课相关信息。在学校内部的现有局域网这个网络环境下,信息由各用户在规定的权限下在各自的工作站上录入,信息上网后各用户可查询,选课,修改,管理,实现信息共享。
2.系统要求与功能设计
2.1 页面要求
(1)系统可以通过浏览器直接访问;(1分)
(2)各个功能页面整体风格统一;(2分)
(3)首页为用户登录页面,管理员、教师、学生三种角色用户登录后,进入相应的功能页,只能看到角色允许访问功能模块;(3分)
图1 学生选课系统功能结构图
(5)学生功能页:共包括查看个人信息、修改个人基本信息、修改个人密码、查询课程信息、自助选课、查询个人课表六项功能模块。
(6)教师功能页:包括查看教师个人信息、修改个人基本信息、修改个人密码、修改个人所教授课程部分信息,查询个人课表五项功能模块;
(7)管理员功能页:新添学生基本信息、修改学生基本信息、删除学生基本信息、新添教师基本信息,修改教师基本信息、删除教师基本信息、新添课程基本信息、修改教师基本信息、删除基本信息,密码重置十项功能模块。
2.2 功能要求
(1)新添学生基本信息:新添一名新学生基本个人信息,学生基本信息包括;学号(数据库中学号保持唯一、由系统自动生成、生成规则:学号由八位数字组成、开头以“2019XXXX”XXXX为四位依次递增的数字序号例如:“20190001、20190002……”)、姓名、性别(限定为“男”或“女”两个选项)、年龄、专业(要求限定在“计算机科学与技术”、“软件工程”、“网络工程”、“数字媒体技术”四个选项)、班级六项基本信息。(5分)
(2)修改学生基本信息(等同于学生功能页中修改个人信息):学号不允许修改,姓名、性别、年龄、专业、班级可以按照要求进行修改,不符合录入格式的,提交时不允许修改,并提示错误信息类型,返回修改界面。(2分)
(3)删除学生基本信息:管理员可以从系统中删除学生基本信息。(1分)
(4)新添教师基本信息:新增一名教师基本信息,教师基本信息包括:教师工号(唯一,六位数字组成,前两位表示学院代码“01表示信息、02表示土木、03表示机械、04、表示电气、05表示交通”,后四位为依次递增的数字序号,提交时应验证工号的正确性,如有误,则提示错误,反馈界面,不允许提交保存)、姓名、职称(职称限定在“助教”、“讲师”、“副教授”、“教授”四个选项)、所属学院(取值限定在“信息、土木、机械、电气、交通”五个选项,并与教师工号前两位形成校验关系);(5分)
(5)修改教师基本信息(等同于教师功能页中修改个人信息):可以修改教师工号,姓名、职称、所属学院,教师工号前两位与所属学院关联,修改任何一项,必须关联修改另外一项,修改提交时须验证是否符合录入格式的,不符合不允许修改,提示错误信息类型,返回修改界面。(2分)
(6)删除教师基本信息:管理员可以从系统中删除教师基本信息,但是如果教师已经承担相应课程,系统不允许删除。(1分)
(7)新添课程基本信息:管理员可以增加一门课程基本信息,课程基本信息包括:课程编号(唯一,六位数字序号,系统自动生成依次递增),课程名称、开课时间(取值限定在“星期一、星期二、星期三、星期四、星期五”),开课节次(取值限定在“1-2节、3-4节、5-6节、7-8节、9-10节”)所属学院(取值限定在“信息、土木、机械、电气、交通”五个选项),任课教师工号,任课教师名称,选课限制人数。(5分)
(8)修改课程基本信息:可以修改课程开课时间、开课节次、所属学院(取值限定在“信息、土木、机械、电气、交通”五个选项),任课教师工号,任课教师名称,选课限制人数六项基本信息,课程编号、课程名称不允许修改。(2分)
(9)删除课程基本信息:管理员可以删除课程基本信息,但如果该课程有学生已经选课,提示错误信息“该课程已经被选,不允许删除”,不允许删除该课程基本信息。(1分)
(10) 自助选课管理:学生登录后可以浏览相关的课程信息列表,并查看课程的详细信息,点击“选课”按钮操作,系统判断该课程是否已超过选课人数,如果超过选课人数限制提示“该课程已经超过选课人数限制,选课失败”,回到选课界面,如果成功,提示“选课成功”。(5分)
(11)查询课表:教师或学生登录系统后均可查询个人课表,学生按照选课结果显示开课时间、开课节次、课程名称,教师按照承担课程显示开课时间、开课节次、课程名称,选课人数;(3分)
(12)修改个人所教授课程部分信息:教师登录后,可以修改个人承担课程的选课人数一项基本信息,其余信息不允许修改;(2分)
(13)个人密码修改:教师或学生用户登录后,可以输入旧密码、新密码、新密码确认修改个人密码,需要判断旧密码是否正确,新密码和新密码确认是否一致;(2分)
(14)重置密码:管理员可以修改教师或学生的个人密码,先按照教师工号或学生学号查询,显示出基本信息后,点击密码重置,将教师或个人密码统一修改为“123456”。(2分)
(15)数据库评分标准:按照题目要求创建教师基本信息表、学生基本信息表、课程基本信息表,选课结果表(4分),实现数据库连接正常(2分)。
一、Dao层 (部分)
public class Dao { //学生添加 public int Sadd(Student student) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "insert into student(SName,SSex,SAge,SZhuan,SClass) value(?,?,?,?,?)"; PreparedStatement pstmt = null; pstmt =connection.prepareStatement(sql); pstmt.setString(1, student.getSName()); pstmt.setString(2, student.getSSex()); pstmt.setString(3, student.getSAge()); pstmt.setString(4, student.getSZhuan()); pstmt.setString(5, student.getSClass()); int count = pstmt.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); return count; } //学生登陆判断 public boolean SDengLu(String name1, String password) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from student where SName=? "; pstmt = connection.prepareStatement(sql); pstmt.setString(1, name1); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { if (name1.equals(rs.getString("SName")) && password.equals(rs.getString("password")) ) { jdbcUtil.close(connection); jdbcUtil.close(pstmt); jdbcUtil.close(rs); return true; } } jdbcUtil.close(connection); jdbcUtil.close(pstmt); jdbcUtil.close(rs); return false; } //学生登陆 public Student SDeng_Lu(String name) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from student where SName=? "; pstmt = connection.prepareStatement(sql); pstmt.setString(1, name); ResultSet rs = pstmt.executeQuery(); Student student = null; while (rs.next()) { int ID = Integer.parseInt(rs.getString("StudentID")); String SName = rs.getString("SName"); String SSex = rs.getString("SSex"); String SAge = rs.getString("SAge"); String SZhuan = rs.getString("SZhuan"); String SClass = rs.getString("SClass"); student = new Student(ID,SName,SSex,SAge,SZhuan,SClass); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return student; } //学生修改密码 public int SUpP(String JID,String XID, String name) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from student where SName=? "; pstmt = connection.prepareStatement(sql); pstmt.setString(1, name); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { if ( JID.equals(rs.getString("password")) ) { PreparedStatement pstmt1 = null; String sql1 = "update student\n" + "set password = ?\n" + "where SName = ?"; pstmt1 = connection.prepareStatement(sql1); pstmt1.setString(1, XID); pstmt1.setString(2, name); int count = pstmt1.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); jdbcUtil.close(pstmt1); jdbcUtil.close(rs); return count; } } jdbcUtil.close(connection); jdbcUtil.close(pstmt); jdbcUtil.close(rs); return 0; } //学生删除 public int Sdel(int id) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "delete from student where StudentID = ?"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); pstmt.setInt(1, id); int count = pstmt.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); return count; } //学生修改 public int Supdate(Student student) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "update student\n" + "set SName = ?,\n" + "SSex = ?,\n" + "SAge = ?,\n" + "SZhuan = ?,\n" + "SClass = ?\n" + "where StudentID = ?"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); pstmt.setString(1, student.getSName()); pstmt.setString(2, student.getSSex()); pstmt.setString(3, student.getSAge()); pstmt.setString(4, student.getSZhuan()); pstmt.setString(5, student.getSClass()); pstmt.setInt(6, student.getStudentID()); int count = pstmt.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); return count; } //学生个人信息 public Student Sget_by_id(int id) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "select * from student where StudentID= ?"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); Student student= null; pstmt.setInt(1,id); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { int ID = Integer.parseInt(rs.getString("StudentID")); String SName = rs.getString("SName"); String SSex = rs.getString("SSex"); String SAge = rs.getString("SAge"); String SZhuan = rs.getString("SZhuan"); String SClass = rs.getString("SClass"); student = new Student(ID,SName,SSex,SAge,SZhuan,SClass); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return student; } //自助选课管理 //学生浏览 public List<KeCheng> selectall() throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "select * from kecheng"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); KeCheng keCheng = null; List<KeCheng> list = new ArrayList<>(); while (rs.next()) { int id = Integer.parseInt(rs.getString("KeChengID")); String KName = rs.getString("KName"); String KTime = rs.getString("KTime"); String KJie = rs.getString("KJie"); String KYuan = rs.getString("KYuan"); int KTid = Integer.parseInt(rs.getString("KTid")); String KTName = rs.getString("KTName"); int KNum = Integer.parseInt(rs.getString("KNum")); int KxNum = Integer.parseInt(rs.getString("KxNum")); keCheng = new KeCheng(id, KName,KTime,KJie, KYuan, KTid, KTName,KxNum); list.add(keCheng); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return list; } //判断选课人数 public boolean Kpan(int KID,int SID) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from kecheng where KeChengID = ?"; pstmt = connection.prepareStatement(sql); pstmt.setInt(1,KID); ResultSet rs = pstmt.executeQuery(); boolean f = false; while (rs.next()) { int KxNum= Integer.parseInt(rs.getString("KxNum")); int KNum = Integer.parseInt(rs.getString("KNum")); if( KxNum >= KNum) { jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return f; } else { int count = KXuan( KID , ++KxNum , SID); if( count > 0 ) { jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return true; } } } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return f; } //选课 public int KXuan(int kid , int num ,int SID) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "update kecheng\n" + "set KxNum = ?\n" + "where KeChengID = ?"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); pstmt.setInt(1, num); pstmt.setInt(2, kid); KB(kid , SID); int count = pstmt.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); return count; } //课表添加 public int KB(int kid ,int SID) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "insert into kebiao(SID,KID) value(?,?)"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); pstmt.setInt(1, SID); pstmt.setInt(2, kid); System.out.println(SID); System.out.println(kid); int count = pstmt.executeUpdate(); jdbcUtil.close(connection); jdbcUtil.close(pstmt); return count; } //选课人数 public int KxNum(int id) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from kecheng where KeChengID = ?"; pstmt = connection.prepareStatement(sql); pstmt.setInt(1,id); ResultSet rs = pstmt.executeQuery(); int count = 0; while (rs.next()) { count= Integer.parseInt(rs.getString("KxNum")); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return count; } //学生个人课表 public List<KeCheng> SKe_biao(int id) throws Exception { Connection connection = jdbcUtil.getconnection(); PreparedStatement pstmt = null; String sql = "select * from kebiao where SID = ?"; pstmt = connection.prepareStatement(sql); pstmt.setInt(1,id); ResultSet rs = pstmt.executeQuery(); KeCheng keCheng = null; List<KeCheng> list = new ArrayList<>(); while (rs.next()) { int KID= Integer.parseInt(rs.getString("KID")); keCheng = Kget_by_id(KID); list.add(keCheng); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return list; } //教师查看个人课表 public List<KeCheng> TKe_biao(int id) throws Exception { Connection connection = jdbcUtil.getconnection(); String sql = "select * from kecheng where KTid= ?"; PreparedStatement pstmt = null; pstmt = connection.prepareStatement(sql); pstmt.setInt(1,id); KeCheng keCheng= null; List<KeCheng> list = new ArrayList<>(); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { int ID = Integer.parseInt(rs.getString("KeChengID")); String KName = rs.getString("KName"); String KTime = rs.getString("KTime"); String KJie = rs.getString("KJie"); String KYuan = rs.getString("KYuan"); int KTid = Integer.parseInt(rs.getString("KTid")); String KTName = rs.getString("KTName"); int KNum = Integer.parseInt(rs.getString("KNum")); int KxNum = Integer.parseInt(rs.getString("KxNum")); keCheng = new KeCheng(ID,KName, KTime, KJie, KYuan, KTid, KTName, KNum , KxNum); list.add(keCheng); } jdbcUtil.close(connection); jdbcUtil.close(pstmt); rs.close(); return list; }
二、pojo(略)
三、util(略)
四、service
public class Service { public boolean Sadd(Student student) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Sadd(student) == 0) { f = false; } return f; } public boolean Tadd(Teacher teacher) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Tadd(teacher) == 0) { f = false; } return f; } public boolean Kadd(KeCheng keCheng) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Kadd(keCheng) == 0) { f = false; } return f; } public List<Student> Ssel_all() throws Exception { Dao dao = new Dao(); return dao.Sselect(); } public Student Sget_by_id(int id) throws Exception { Dao dao = new Dao(); return dao.Sget_by_id(id); } public boolean Supdate(Student student) throws Exception { Dao dao = new Dao(); boolean f = false; int count = dao.Supdate(student); if(count != 0) { f = true; } return f; } public List<Teacher> Tsel_all() throws Exception { Dao dao = new Dao(); return dao.Tselect(); } public boolean Sdel(int id) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Sdel(id) == 0) { f = false; } return f; } public Teacher Tget_by_id(int id) throws Exception { Dao dao = new Dao(); return dao.Tget_by_id(id); } public boolean Tupdate(Teacher teacher) throws Exception { Dao dao = new Dao(); boolean f = false; int count = dao.Tupdate(teacher); if(count != 0) { f = true; } return f; } public boolean Tdel(int id) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Tdel(id) == 0) { f = false; } return f; } public KeCheng Kget_by_id(int id) throws Exception { Dao dao = new Dao(); return dao.Kget_by_id(id); } public List<KeCheng> Ksel_all() throws Exception { Dao dao = new Dao(); return dao.Kselect(); } public boolean Kupdate(KeCheng keCheng) throws Exception { Dao dao = new Dao(); boolean f = false; int count = dao.Kupdate(keCheng); if(count != 0) { f = true; } return f; } public boolean Kdel(int id) throws Exception { Dao dao = new Dao(); boolean f = true; if(dao.Kdel(id) == 0) { f = false; } return f; } public boolean KxNum(int id) throws Exception { Dao dao = new Dao(); boolean f = false; if(dao.KxNum(id) == 0) { f = true; } return f; } public boolean Sdenglu(String password, String sName) throws Exception { Dao dao = new Dao(); return dao.SDengLu(sName , password); } public Student SDeng_Lu( String sName) throws Exception { Dao dao = new Dao(); return dao.SDeng_Lu(sName); } public boolean Tdenglu(String password, String tName) throws Exception { Dao dao = new Dao(); return dao.TDengLu(tName , password); } public Teacher TDeng_Lu( String tName) throws Exception { Dao dao = new Dao(); return dao.TDeng_Lu(tName); } public boolean SUpP(String name, String jid, String xid) throws Exception { Dao dao = new Dao(); boolean f = false; if(dao.SUpP(jid , xid ,name) != 0) { f = true; } return f; } public boolean TUpP(String name, String jid, String xid) throws Exception { Dao dao = new Dao(); boolean f = false; if(dao.TUpP(jid , xid ,name) != 0) { f = true; } return f; } public boolean Kpan(int kid, int sid) throws Exception { Dao dao = new Dao(); return dao.Kpan(kid, sid); } public List<KeCheng> SKe_biao(int sid) throws Exception { Dao dao = new Dao(); return dao.SKe_biao(sid); } public List<KeCheng> TKe_biao(int id) throws Exception { Dao dao = new Dao(); return dao.TKe_biao(id); } }
五、servlet
(一)S_Servlet
@WebServlet("/S_Servlet") public class S_Servlet extends HttpServlet { Service service = new Service(); @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String method = request.getParameter("method"); if("add".equals(method)) { try { Sadd(request , response); } catch (Exception e) { e.printStackTrace(); } } else if ("del".equals(method)) { try { Sdel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("update".equals(method)) { try { Supdate(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("sel".equals(method)) { try { Ssel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Sget_by_id".equals(method)) { try { Sget_by_id(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Sget_by_ID".equals(method)) { try { Sget_by_ID(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Sdeng_lu".equals(method)) { try { Sdeng_lu(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("SUpP".equals(method)) { try { SUpP(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("remi".equals(method)) { try { remi(request, response); } catch (Exception e) { e.printStackTrace(); } } } private void SUpP(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String name = request.getParameter("name"); String JID = request.getParameter("password1"); String XID = request.getParameter("password2"); if (service.SUpP(name,JID,XID)) { request.setAttribute("message" , "修改成功"); }else{ request.setAttribute("message" , "修改失败"); } request.getRequestDispatcher("SUpP.jsp").forward(request,response); } private void remi(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); Student student = service.Sget_by_id(ID); request.setAttribute("student",student); request.getRequestDispatcher("Sremi.jsp").forward(request,response); } private void Sdeng_lu(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String SName = request.getParameter("SName"); String password = request.getParameter("password"); if (service.Sdenglu(password, SName)) { request.setAttribute("message", "登录成功"); Student student = service.SDeng_Lu(SName); request.setAttribute("student",student); request.getRequestDispatcher("S_Jie_Mian.jsp").forward(request, response); } else { request.setAttribute("message", "登录失败"); request.getRequestDispatcher("S_Deng_lu.jsp").forward(request, response); } } private void Sget_by_id(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); Student student = service.Sget_by_id(ID); request.setAttribute("student",student); request.getRequestDispatcher("Supdate.jsp").forward(request,response); } private void Sget_by_ID(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); Student student = service.Sget_by_id(ID); request.setAttribute("student",student); request.getRequestDispatcher("Sget_by_ID.jsp").forward(request,response); } private void Ssel(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); List<Student> list = service.Ssel_all(); request.setAttribute("list" , list); request.getRequestDispatcher("Ssel.jsp").forward(request,response); } private void Supdate(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); String SName = request.getParameter("SName"); String SSex = request.getParameter("SSex"); String SAge = request.getParameter("SAge"); String SZhuan = request.getParameter("SZhuan"); String SClass = request.getParameter("SClass"); Student student = new Student(ID,SName,SSex,SAge,SZhuan,SClass); if (service.Supdate(student)) { request.setAttribute("message" , "修改成功"); }else{ request.setAttribute("message" , "修改失败"); } request.getRequestDispatcher("S_Servlet?method=sel").forward(request,response); } private void Sdel(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); int id = Integer.parseInt( request.getParameter("id")); if(service.Sdel(id)) { request.setAttribute("message" , "删除成功"); }else{ request.setAttribute("message" , "删除失败"); } request.getRequestDispatcher("S_Servlet?method=sel").forward(request,response); } private void Sadd(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String SName = request.getParameter("SName"); String SSex = request.getParameter("SSex"); String SAge = request.getParameter("SAge"); String SZhuan = request.getParameter("SZhuan"); String SClass = request.getParameter("SClass"); Student student = new Student(SName,SSex,SAge,SZhuan,SClass); if (service.Sadd(student)) { request.setAttribute("message" , "添加成功"); }else{ request.setAttribute("message" , "添加失败"); } request.getRequestDispatcher("Sadd.jsp").forward(request,response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
(二)T_Servlet
@WebServlet("/T_Servlet") public class T_Servlet extends HttpServlet { Service service = new Service(); @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String method =request.getParameter("method"); if("add".equals(method)) { try { Tadd(request , response); } catch (Exception e) { e.printStackTrace(); } } else if ("del".equals(method)) { try { Tdel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("update".equals(method)) { try { Tupdate(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("sel".equals(method)) { try { Tsel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Tget_by_id".equals(method)) { try { Tget_by_id(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Tget_by_ID".equals(method)) { try { Tget_by_ID(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Tdeng_lu".equals(method)) { try { Tdeng_lu(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("TUpP".equals(method)) { try { TUpP(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("TKe_biao".equals(method)) { try { TKe_biao(request, response); } catch (Exception e) { e.printStackTrace(); } } } private void TKe_biao(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); List<KeCheng> list = service.TKe_biao(ID); request.setAttribute("list",list); request.getRequestDispatcher("TKe_biao.jsp").forward(request,response); } private void TUpP(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String name = request.getParameter("name"); String JID = request.getParameter("password1"); String XID = request.getParameter("password2"); if (service.TUpP(name,JID,XID)) { request.setAttribute("message" , "修改成功"); }else{ request.setAttribute("message" , "修改失败"); } request.getRequestDispatcher("TUpP.jsp").forward(request,response); } private void Tdeng_lu(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String SName = request.getParameter("TName"); String password = request.getParameter("password"); if (service.Tdenglu(password , SName)) { request.setAttribute("message" , "登录成功"); Teacher teacher = service.TDeng_Lu(SName); request.setAttribute("teacher",teacher); request.getRequestDispatcher("T_Jie_mian.jsp").forward(request,response); }else{ request.setAttribute("message" , "登录失败"); request.getRequestDispatcher("T_Deng_lu.jsp").forward(request,response); } } private void Tget_by_id(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); Teacher teacher = service.Tget_by_id(ID); request.setAttribute("teacher",teacher); request.getRequestDispatcher("Tupdate.jsp").forward(request,response); } private void Tget_by_ID(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); Teacher teacher = service.Tget_by_id(ID); request.setAttribute("teacher",teacher); request.getRequestDispatcher("T_get_by_ID.jsp").forward(request,response); } private void Tsel(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); List<Teacher> list = service.Tsel_all(); request.setAttribute("list" , list); request.getRequestDispatcher("Tsel.jsp").forward(request,response); } private void Tupdate(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); String TName = request.getParameter("TName"); String TZhi = request.getParameter("TZhi"); String TYuan = request.getParameter("TYuan"); Teacher teacher = new Teacher(ID,TName,TZhi,TYuan); if (service.Tupdate(teacher)) { request.setAttribute("message" , "修改成功"); }else{ request.setAttribute("message" , "修改失败"); } request.getRequestDispatcher("T_Servlet?method=sel").forward(request,response); } private void Tdel(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); int id = Integer.parseInt( request.getParameter("id")); if(service.Tdel(id)) { request.setAttribute("message" , "删除成功"); }else{ request.setAttribute("message" , "删除失败"); } request.getRequestDispatcher("T_Servlet?method=sel").forward(request,response); } private void Tadd(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int id = Integer.parseInt(request.getParameter("TeacherID")); String TName = request.getParameter("TName"); String TZhi = request.getParameter("TZhi"); String TYuan = request.getParameter("TYuan"); Teacher teacher = new Teacher(id,TName,TZhi,TYuan); if (service.Tadd(teacher)) { request.setAttribute("message" , "添加成功"); }else{ request.setAttribute("message" , "添加失败"); } request.getRequestDispatcher("Tadd.jsp").forward(request,response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
(三)K_Servlet
@WebServlet("/K_Servlet") public class K_Servlet extends HttpServlet { Service service = new Service(); @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String method =request.getParameter("method"); if("add".equals(method)) { try { Kadd(request , response); } catch (Exception e) { e.printStackTrace(); } } else if ("del".equals(method)) { try { Kdel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("update".equals(method)) { try { Kupdate(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("sel".equals(method)) { try { Ksel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Kget_by_id".equals(method)) { try { Kget_by_id(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("KTget_by_id".equals(method)) { try { KTget_by_id(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("Ssel".equals(method)) { try { Ssel(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("KXuan".equals(method)) { try { KXuan(request, response); } catch (Exception e) { e.printStackTrace(); } } else if ("SKe_biao".equals(method)) { try { SKe_biao(request, response); } catch (Exception e) { e.printStackTrace(); } } } private void SKe_biao(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); List<KeCheng> list = service.SKe_biao( ID ); request.setAttribute("list" , list); request.getRequestDispatcher("SKe_biao.jsp").forward(request,response); } private void KXuan(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int KID = Integer.parseInt( request.getParameter("KID")); int SID = Integer.parseInt( request.getParameter("SID")); if(service.Kpan(KID,SID)) { request.setAttribute("message" , "选课成功"); }else{ request.setAttribute("message" , "该课程已经超过选课人数限制,选课失败"); } request.getRequestDispatcher("K_Ssel.jsp").forward(request,response); } private void Ssel(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); List<KeCheng> list = service.Ksel_all(); int ID = Integer.parseInt( request.getParameter("id")); request.setAttribute("list" , list); Student student = new Student(); student.setStudentID(ID); request.setAttribute("student",student); request.getRequestDispatcher("K_Ssel.jsp").forward(request,response); } private void Kget_by_id(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); KeCheng keCheng = service.Kget_by_id(ID); request.setAttribute("keCheng",keCheng); request.getRequestDispatcher("Kupdate.jsp").forward(request,response); } private void KTget_by_id(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); KeCheng keCheng = service.Kget_by_id(ID); request.setAttribute("keCheng",keCheng); request.getRequestDispatcher("KTupdate.jsp").forward(request,response); } private void Ksel(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); List<KeCheng> list = service.Ksel_all(); request.setAttribute("list" , list); request.getRequestDispatcher("Ksel.jsp").forward(request,response); } private void Kupdate(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); int ID = Integer.parseInt( request.getParameter("id")); String KName = request.getParameter("KName"); String KTime = request.getParameter("KTime"); String KJie = request.getParameter("KJie"); String KYuan = request.getParameter("KYuan"); int KTid = Integer.parseInt(request.getParameter("KTid")); String KTName = request.getParameter("KTName"); int KNum = Integer.parseInt(request.getParameter("KNum")); KeCheng keCheng = new KeCheng(ID,KName,KTime,KJie, KYuan, KTid, KTName,KNum); if (service.Kupdate(keCheng)) { request.setAttribute("message" , "修改成功"); }else{ request.setAttribute("message" , "修改失败"); } request.getRequestDispatcher("K_Servlet?method=sel").forward(request,response); } private void Kdel(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); int id = Integer.parseInt( request.getParameter("id")); if(service.Kdel(id) && service.KxNum(id)) { request.setAttribute("message" , "删除成功"); } else if( !service.KxNum(id) ){ request.setAttribute("message" , "该课程已经被选,不允许删除"); } request.getRequestDispatcher("K_Servlet?method=sel").forward(request,response); } private void Kadd(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String KName = request.getParameter("KName"); String KTime = request.getParameter("KTime"); String KJie = request.getParameter("KJie"); String KYuan = request.getParameter("KYuan"); int KTid = Integer.parseInt(request.getParameter("KTid")); String KTName = request.getParameter("KTName"); int KNum = Integer.parseInt(request.getParameter("KNum")); KeCheng keCheng = new KeCheng(KName,KTime,KJie, KYuan, KTid, KTName,KNum); if (service.Kadd(keCheng)) { request.setAttribute("message" , "添加成功"); }else{ request.setAttribute("message" , "添加失败"); } request.getRequestDispatcher("Kadd.jsp").forward(request,response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
六、JSP
(一)菜单
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 13:56 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>石家庄铁道大学学生选课管理系统</title> </head> <body> <div align="center"> <div class="a"> <input type="button" value="学生" onclick="location.href='S_Deng_lu.jsp'"/> </div> <div class="a"> <input type="button" value="教师" onclick="location.href='T_Deng_lu.jsp'"/> </div> <div class="a"> <input type="button" value="管理员" onclick="location.href='G_Jie_Mian.jsp'"/> </div> </div> </body> </html>
(二)管理员
管理员菜单 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 15:58 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <div align="center"> <div class="a"> <input type="button" value="新添学生基本信息" onclick="location.href='Sadd.jsp'"/> </div> <div class="a"> <input type="button" value="修改学生基本信息" onclick="location.href='S_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="删除学生基本信息" onclick="location.href='S_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="新添教师基本信息" onclick="location.href='Tadd.jsp'"/> </div> <div class="a"> <input type="button" value="修改教师基本信息" onclick="location.href='T_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="删除教师基本信息" onclick="location.href='T_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="新添课程基本信息" onclick="location.href='Kadd.jsp'"/> </div> <div class="a"> <input type="button" value="修改课程基本信息" onclick="location.href='K_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="删除课程信息" onclick="location.href='K_Servlet?method=sel'"/> </div> <div class="a"> <input type="button" value="密码重置" onclick="location.href='remi.jsp'"/> </div> </div> </body> </html> 课程添加 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 16:53 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: black;">添加学生信息</h1> <form name="form3" action="K_Servlet?method=add" method="post" onsubmit="return check()"> <table align="center" border="1" width="1000"> <tr> <td>课程名称</td> <td> <label> <input type="text" name="KName" /> </label> </td> </tr> <tr> <td>开课时间 </td> <td> <label> <input type="radio" name="KTime" value="星期一"checked>星期一 <input type="radio" name="KTime" value="星期二">星期二 <input type="radio" name="KTime" value="星期三">星期三 <input type="radio" name="KTime" value="星期四">星期四 <input type="radio" name="KTime" value="星期五">星期五 </label> </td> </tr> <tr> <td>开课节次 </td> <td> <label> <input type="radio" name="KJie" value="1-2节"checked>1-2节 <input type="radio" name="KJie" value="3-4节">3-4节 <input type="radio" name="KJie" value="5-6节">5-6节 <input type="radio" name="KJie" value="7-8节">7-8节 <input type="radio" name="KJie" value="9-10节">9-10节 </label> </td> </tr> <tr> <td>所属学院</td> <td> <label> <input type="radio" name="KYuan" value="信息"checked>信息 <input type="radio" name="KYuan" value="土木">土木 <input type="radio" name="KYuan" value="机械">机械 <input type="radio" name="KYuan" value="电气">电气 <input type="radio" name="kYuan" value="交通">交通 </label> </td> </tr> <tr> <td>任课教师工号</td> <td> <label> <input type="text" name="KTid" /> </label> </td> </tr> <tr> <td>任课教师名称</td> <td> <label> <input type="text" name="KTName" /> </label> </td> </tr> <tr> <td>选课限制人数</td> <td> <label> <input type="text" name="KNum" /> </label> </td> </tr> <tr align="center"> <td colspan="3"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <a href="index.jsp">返回主页</a> </td> </tr> </table> </form> </div> </body> </html> 课程浏览 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/12 Time: 17:39 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message != null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%}%> <div align="center"> <h1 style="color: black;">信息列表</h1> <table border="1px"> <tr> <td>课程编号</td> <td>课程名称</td> <td>开课时间</td> <td>开课节次</td> <td>所属学院</td> <td>任课教师工号</td> <td>任课教师名称</td> <td>选课限制人数</td> <td>已选课人数</td> </tr> <c:forEach items="${list}" var="item"> <tr> <td>${item.keChengID}</td> <td>${item.KName}</td> <td>${item.KTime}</td> <td>${item.KJie}</td> <td>${item.KYuan}</td> <td>${item.KTid}</td> <td>${item.KTName}</td> <td>${item.KNum}</td> <td>${item.kxNum}</td> <td><a href="K_Servlet?method=Kget_by_id&&id=${item.keChengID}">修改</a></td> <td><a href="K_Servlet?method=del&&id=${item.keChengID}">删除</a></td> <td><a href="index.jsp">返回主页</a></td> </tr> </c:forEach> </table> </div> </body> </html> 课程修改 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/12 Time: 17:39 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: black;">修改课程信息</h1> <form name="form3" action="K_Servlet?method=update&&id=${requestScope.keCheng.keChengID}" method="post" onsubmit="return check()"> <table align="center" border="1" width="1000"> <tr> <td>课程编号</td> <td> <label> <input value="${requestScope.keCheng.keChengID}"/> </label> </td> </tr> <tr> <td>课程名称</td> <td> <label> <input type="text" name="KName" value="${requestScope.keCheng.KName}" readonly="readonly"/> </label> </td> </tr> <tr> <td>开课时间 </td> <td> <label> <input type="radio" name="KTime" value="星期一"checked>星期一 <input type="radio" name="KTime" value="星期二">星期二 <input type="radio" name="KTime" value="星期三">星期三 <input type="radio" name="KTime" value="星期四">星期四 <input type="radio" name="KTime" value="星期五">星期五 </label> </td> </tr> <tr> <td>开课节次 </td> <td> <label> <input type="radio" name="KJie" value="1-2节"checked>1-2节 <input type="radio" name="KJie" value="3-4节">3-4节 <input type="radio" name="KJie" value="5-6节">5-6节 <input type="radio" name="KJie" value="7-8节">7-8节 <input type="radio" name="KJie" value="9-10节">9-10节 </label> </td> </tr> <tr> <td>所属学院</td> <td> <label> <input type="radio" name="KYuan" value="信息"checked>信息 <input type="radio" name="KYuan" value="土木">土木 <input type="radio" name="KYuan" value="机械">机械 <input type="radio" name="KYuan" value="电气">电气 <input type="radio" name="KYuan" value="交通">交通 </label> </td> </tr> <tr> <td>任课教师工号</td> <td> <label> <input type="text" name="KTid" value="${requestScope.keCheng.KTid}"/> </label> </td> </tr> <tr> <td>任课教师名称</td> <td> <label> <input type="text" name="KTName" value="${requestScope.keCheng.KTName}"/> </label> </td> </tr> <tr> <td>选课限制人数</td> <td> <label> <input type="text" name="KNum" value="${requestScope.keCheng.KNum}"/> </label> </td> </tr> <tr align="center"> <td colspan="3"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <a href="index.jsp">返回主页</a> </td> </tr> </table> </form> </div> </body> </html>
(三)学生
学生登录 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/18 Time: 14:42 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message != null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%}%> <div align="center"> <h1 style="color: black;">学生登录</h1> <form name="form3" action="S_Servlet?method=Sdeng_lu" method="post" > <table align="center"> 请输入姓名:<input type="text" name="SName" /><br> 请输入密码:<input type="text" name="password" /><br> <input type="submit" value="登录" /> </table> </form> </div> </body> </html> 学生添加
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 15:53 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <div align="center"> <h1 style="color: black;">添加学生信息</h1> <form name="form1" action="S_Servlet?method=add" method="post" onsubmit="return check()"> <table align="center" border="1" width="1000"> <tr> <td>姓名</td> <td> <label> <input type="text" name="SName"/> </label> </td> </tr> <tr> <td>性别 </td> <td> <label> <input type="radio" name="SSex" value="男"checked>男 <input type="radio" name="SSex" value="女">女 </label> </td> </tr> <tr> <td>年龄</td> <td> <label> <input type="text" name="SAge" /> </label> </td> </tr> <tr> <td>专业 </td> <td> <label> <input type="radio" name="SZhuan" value="计算机科学与技术"checked>计算机科学与技术 <input type="radio" name="SZhuan" value="软件工程">软件工程 <input type="radio" name="SZhuan" value="网络工程">网络工程 <input type="radio" name="SZhuan" value="数字媒体技术">数字媒体技术 </label> </td> </tr> <tr> <td>班级</td> <td> <label> <input type="text" name="SClass" /> </label> </td> </tr> <tr align="center"> <td colspan="3"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <a href="index.jsp">返回主页</a> </td> </tr> </table> </form> </div> </body> </html> 学生主界面
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 15:57 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message != null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%}%> <div align="center"> <div class="a"> <input type="button" value="查看个人信息" onclick="location.href='S_Servlet?method=Sget_by_ID&&id=${requestScope.student.studentID}'"/> </div> <div class="a"> <input type="button" value="修改个人基本信息" onclick="location.href='S_Servlet?method=Sget_by_id&&id=${requestScope.student.studentID}'"/> </div> <div class="a"> <input type="button" value="修改个人密码" onclick="location.href='SUpP.jsp'"/> </div> <div class="a"> <input type="button" value="查询课程信息" onclick="location.href='K_Servlet?method=Ssel&&id=${requestScope.student.studentID}'"/> </div> <div class="a"> <input type="button" value="自助选课" onclick="location.href='K_Servlet?method=Ssel&&id=${requestScope.student.studentID}'"/> </div> <div class="a"> <input type="button" value="查询个人课表" onclick="location.href='K_Servlet?method=SKe_biao&&id=${requestScope.student.studentID}'"/> </div> </div> </body> </html> 学生修改密码
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/18 Time: 21:22 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <div align="center"> <h1 style="color: black;">信息</h1> <form name="form1" action="S_Servlet?method=update&&id=${requestScope.student.studentID}" method="post" onsubmit="return check()"> <table align="center" border="1" width="500"> <tr> <td>姓名</td> <td> <label> <input value="${requestScope.student.SName}" /> </label> </td> </tr> <tr> <td>性别 </td> <td> <label> <input type="radio" name="SSex" value="男"checked>男 <input type="radio" name="SSex" value="女">女 </label> </td> </tr> <tr> <td>年龄</td> <td> <label> <input type="text" name="SAge" value="${requestScope.student.SAge}" /> </label> </td> </tr> <tr> <td>专业 </td> <td> <label> <input type="radio" name="SZhuan" value="计算机科学与技术"checked>计算机科学与技术 <input type="radio" name="SZhuan" value="软件工程">软件工程 <input type="radio" name="SZhuan" value="网络工程">网络工程 <input type="radio" name="SZhuan" value="野外采风">数字媒体技术 </label> </td> </tr> <tr> <td>班级</td> <td> <label> <input type="text" name="SClass" value="${requestScope.student.SClass}"/> </label> </td> </tr> <tr align="center"> <td colspan="3"> <input type="submit" value="提交" /> <input type="reset" value="重置" /> <a href="index.jsp">返回主页</a> </td> </tr> </table> </form> </div> </body> </html> 学生查看个人课表
<%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/18 Time: 17:31 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message != null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%}%> <div align="center"> <h1 style="color: black;">个人课表</h1> <table border="1px"> <tr> <td>课程名称</td> <td>开课时间</td> <td>开课节次</td> </tr> <c:forEach items="${list}" var="item"> <tr> <td>${item.KName}</td> <td>${item.KTime}</td> <td>${item.KJie}</td> <td><a href="index.jsp">返回主页</a></td> </tr> </c:forEach> </table> </div> </body> </html>
(四)教师
教师主界面 <%-- Created by IntelliJ IDEA. User: wanghongbing Date: 2022/11/11 Time: 15:57 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <% Object message = request.getAttribute("message"); if(message != null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%}%> <div align="center"> <div class="a"> <input type="button" value="查看个人信息" onclick="location.href='T_Servlet?method=Tget_by_ID&&id=${requestScope.teacher.teacherID}'"/> </div> <div class="a"> <input type="button" value="修改个人基本信息" onclick="location.href='T_Servlet?method=Tget_by_id&&id=${requestScope.teacher.teacherID}'"/> </div> <div class="a"> <input type="button" value="修改个人密码" onclick="location.href='TUpP.jsp'"/> </div> <div class="a"> <input type="button" value="修改个人所教授课程" onclick="location.href='T_Servlet?method=TKe_biao&&id=${requestScope.teacher.teacherID}'"/> </div> <div class="a"> <input type="button" value="查询个人课表" onclick="location.href='T_Servlet?method=TKe_biao&&id=${requestScope.teacher.teacherID}'"/> </div> </div> </body> </html>标签:Exception,String,选课,石家庄,request,id,铁道,response,pstmt From: https://www.cnblogs.com/ruipengli/p/16998311.html