石家庄铁道大学选课管理系统2
jsp
主界面
<%@ page import="Bean.student" %> <%@ page import="java.util.List" %> <%@ page import="Dao.dao" %><%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/26 Time: 13:42 To change this template use File | Settings | File Templates. --%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>石家庄铁道大学选课管理系统</title> <style type="text/css"> .bg { background-image:url("src/图片1"); background-size:cover; } *{font-style: "微软雅黑"} #table{ border-collapse: collapse; margin: auto;text-align: center;} #table th{background-color: #fff7d5;border: 1px solid black;} #table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;} #table a{text-decoration: none;font-weight: bold;} #table a:hover {text-decoration: underline;} </style> </head> <body> <form method="post" action="houtai.jsp" class="form-login"> <h2 style="text-align: center;">石家庄铁道大学选课系统</h2> <br> <div style="text-align: center;"> <tr> <td>身份: <select name="profession"> <option value="1">管理员</option> <option value="2">教师</option> <option value="3" selected>学生</option> </select> </td> </tr> <tr><td> 用户名:<input type="text" name="username"><br></tr> <tr><td> 密码:<input pattern="[a-zA-Z0-9]{6,12}" type="password" name="password"></td> </tr> </div> <tr> <td colspan="2"><div align="center"> <input type="submit" value="登录"></div></td> </tr> </table> </form> </div> </body> </html>
houtai.jsp
<%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/26 Time: 23:15 To change this template use File | Settings | File Templates. --%> <%@ page import="java.sql.*" contentType="text/html;charset=UTF-8" language="java" %> <%@ page import="Bean.lesson" %> <head> <title>从index获取数据</title> </head> <body> <% //获取前端index的登录数据 request.setCharacterEncoding("UTF-8");//编码一定设置 String profession=request.getParameter("profession"); String username=request.getParameter("username"); String password=request.getParameter("password");//取出login.jsp的值 //1.将Driver驱动加载进jvm try { Class.forName ("com.mysql.cj.jdbc.Driver"); } catch (ClassNotFoundException e) { e.printStackTrace(); } String mysqlname = "xuanke"; String url = "jdbc:mysql://localhost:3306/"+mysqlname+"?serverTimezone=UTC"; Connection cnn=null; Statement st = null; try { //2.创建链接对象 cnn = DriverManager.getConnection (url, "root", "123456"); //3。创建sql语句 String sql = "select * from userdata where username=" + "'" + username + "'";//定义一个查询语句 System.out.println (sql); //创建链接管道 st = cnn.createStatement (); //4.执行sql语句 ResultSet res=st.executeQuery(sql);//运行上面的语句 res.getObject("password"); if (password.equals("123456")){ switch(profession) { case "1":response.sendRedirect("manager.jsp");break; case "2": String teacher=request.getParameter("username"); // session.setAttribute("teacher", teacher); request.setAttribute("teacher", teacher); response.sendRedirect("teacher.jsp");break; case "3":String student=request.getParameter("username"); // session.setAttribute("teacher", teacher); request.setAttribute("student", student); response.sendRedirect("student.jsp");break; } } else { out.print("<script language='javaScript'> alert('密码错误');</script>"); response.setHeader("refresh", "0;url=index.jsp"); } }catch (Exception ignored){ } %> </body> </html>
student
<%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/26 Time: 15:38 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta charset="UTF-8"> <title>学生功能页面</title> <style type="text/css"> .bg { background-image:url(images/bg_2.jpg); background-size:cover; } *{font-style: "微软雅黑"} #table{ border-collapse: collapse; margin: auto;text-align: center;} #table th{background-color: #fff7d5;border: 1px solid black;} #table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;} #table a{text-decoration: none;font-weight: bold;} #table a:hover {text-decoration: underline;} </style> </head> <body class="bg"> <h2 style="text-align: center;">你好!同学,请选择以下操作</h2> <br> <div style="text-align: center;"> <a href="update.jsp" target="_self">修改个人信息</a><br> <a href="add.jsp" target="_self">浏览课程信息</a><br> <a href="add.jsp" target="_self">选课</a><br> </div> <br> <% request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); %> </body> </html>
teacher
<%@ page import="Bean.lesson" %><%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/26 Time: 16:02 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta charset="UTF-8"> <title>教师功能页面</title> <style type="text/css"> .bg { background-image:url(images/bg_2.jpg); background-size:cover; } *{font-style: "微软雅黑"} #table{ border-collapse: collapse; margin: auto;text-align: center;} #table th{background-color: #fff7d5;border: 1px solid black;} #table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;} #table a{text-decoration: none;font-weight: bold;} #table a:hover {text-decoration: underline;} </style> </head> <body class="bg"> <h2 style="text-align: center;">你好!教师,请选择以下操作</h2> <br> <div style="text-align: center;"> <a href="update2.jsp" target="_self">修改个人信息</a><br> <a href="add.jsp" target="_self">浏览选课学生信息</a><br> <a href="add3.jsp" target="_self">添加课程</a><br> </div> <br> <% request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); %> </body> </html>
manager
<%-- Created by IntelliJ IDEA. User: 榕宝 Date: 2021/11/26 Time: 15:39 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <meta charset="UTF-8"> <title>管理员功能页面</title> <style type="text/css"> .bg { background-image:url(images/bg_2.jpg); background-size:cover; } *{font-style: "微软雅黑"} #table{ border-collapse: collapse; margin: auto;text-align: center;} #table th{background-color: #fff7d5;border: 1px solid black;} #table td{background-color:#cffcd5;border: 1px solid black;padding: 15px;color: #000;} #table a{text-decoration: none;font-weight: bold;} #table a:hover {text-decoration: underline;} </style> </head> <body class="bg"> <h2 style="text-align: center;">你好!管理员,请选择以下操作</h2> <br> <div style="text-align: center;"> <a href="add.jsp" target="_self">添加学生信息</a><br> <a href="add2.jsp" target="_self">添加教师信息</a><br> </div> <br> <% request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); %> </body> </html>