基于JavaWeb的简单在线选课系统(idea使用,版本原因,需要修改些许代码去适应个人的idea配置)

     阅读:23

本系统主要技术包括jsp、servlet、JavaBean、数据库运用mysql,调用数据库技术用的是util,也可根据自己要求修改成spring的ssm框架去调用数据库简化代码,防止冗余。

此系统是一个简单的在线选课系统,满足三方人员的使用(管理员,教师,学生),学生能通过系统进行选课,老师能通过系统进行添加课程,管理员能通过系统进行添加人员,在个人登录后,将拥有相关人员登录的权限,例如学生的浏览课程,老师的浏览选课。

用户角色划分

  1. 管理员

使用本系统的后台功能,可以进行教师和学生的添加

  1. 教师

使用本系统的前台功能,可以进行课程的添加,教师本人信息的修改,选课信息的查找。

      3、学生

使用本系统的前台功能,可以进行选课信息的查找,学生本人信息的修改以及课程的选择。

用户登录及功能设计:

一.管理员登录及功能设计:

2.教师登录及用户设计:

 3.学生登录及用户设计:

数据库登录设计:(此登录设计往后学习到SSM框架后可用Spring的applicationContext去代替访问数据库,减少代码量,访问更加快速直接:如下图二)

 

二. 网页界面以及各页面间跳转设计:

1.管理员界面设计:

2.教师界面设计:

3.学生界面设计:

 4.登录界面以及主界面设计:

 三.代码设计:

1.java代码:

Guanli包:

Add类:

package online_select.Guanli;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Add {
    public boolean add(String table,AddService en)
    {
        boolean c=false;
        String sql="insert into "+table+"(username,password,power,name) values"
                + "('"+en.getUsername()+"','"+en.getPassword()+"','"+en.getPower()+"','"+en.getName()+"');";
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            int num=state.executeUpdate(sql);
            if(num!=0)
                c=true;


            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }


        return c;

    }
    public boolean add(String table,TeacherService en)
    {
        boolean c=false;
        String sql="insert into "+table+"(teac_id,teac_name,teac_sex,college,postion) values"
                + "('"+en.getTeac_id()+"','"+en.getTeac_name()+"','"+en.getTeac_sex()+"','"+en.getCollege()+"','"+en.getPostion()+"');";
        Connection conn=DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            int num=state.executeUpdate(sql);
            if(num!=0)
                c=true;


            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }


        return c;

    }
    public boolean add(String table,StudentService en)
    {
        boolean c=false;
        String s = "','" + en.getCollege() + "');";
        String sql="insert into "+table+"(stu_id,stu_name,stu_sex,class_name,college) values"
                + "('"+en.getStu_id()+"','"+en.getStu_name()+"','"+en.getStu_sex()+"','"+en.getStu_sex()+"','"+en.getCollege()+"');";
        Connection conn=DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            int num=state.executeUpdate(sql);
            if(num!=0)
                c=true;


            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }


        return c;

    }

}

AddService类:

package online_select.Guanli;

public class AddService {
    String username;
    String password;
    String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    int power;
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public int getPower() {
        return power;
    }
    public void setPower(int power) {
        this.power = power;
    }

}

RegisterServlet类:

package online_select.Guanli;


import online_select.Login.Select;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class RegisterServlet
 */
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public RegisterServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        @SuppressWarnings("unused")
        Select s=new Select();
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("teacher"))
        {
            AddService as=new AddService();
            Add a=new Add();
            String username;
            username=arg0.getParameter("username");
            as.setUsername(username);
            String password;
            password=arg0.getParameter("password");
            as.setPassword(password);
            int num=1;
            as.setPower(num);

            TeacherService ts=new TeacherService();
            String teac_id;
            teac_id=arg0.getParameter("teac——id");
            ts.setTeac_id(teac_id);
            String teac_name;
            teac_name=arg0.getParameter("teac_name");
            ts.setTeac_name(teac_name);
            as.setName(teac_name);
            String teac_sex;
            teac_sex=arg0.getParameter("teac_sex");
            ts.setTeac_sex(teac_sex);
            String college;
            college=arg0.getParameter("college");
            ts.setCollege(college);
            String postion;
            postion=arg0.getParameter("ostion");
            ts.setPostion(postion);
            a.add("login", as);
            a.add("teacher", ts);
            arg0.setAttribute("message","添加成功");
            arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);

        }
        if(function.equals("student"))
        {
            AddService as=new AddService();
            Add a=new Add();
            String username;
            username=arg0.getParameter("username");
            as.setUsername(username);
            String password;
            password=arg0.getParameter("password");
            as.setPassword(password);

            int num=2;
            as.setPower(num);

            StudentService ss=new StudentService();
            String stu_id;
            stu_id=arg0.getParameter("stu_id");
            ss.setStu_id(stu_id);
            String stu_name;
            stu_name=arg0.getParameter("stu_name");
            ss.setStu_name(stu_name);
            as.setName(stu_name);
            String stu_sex;
            stu_sex=arg0.getParameter("stu_sex");
            ss.setStu_sex(stu_sex);
            String class_name;
            class_name=arg0.getParameter("class_name");
            ss.setClass_name(class_name);
            String college;
            college=arg0.getParameter("college");
            ss.setCollege(college);
            a.add("student", ss);
            a.add("login", as);
            arg0.setAttribute("message","添加成功");
            arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

StudentServicelei:

package online_select.Guanli;

public class StudentService {
    String stu_id;
    String stu_name;
    String stu_sex;
    String class_name;
    String college;

    public String getStu_id() {
        return stu_id;
    }

    public void setStu_id(String stu_id) {
        this.stu_id = stu_id;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getClass_name() {
        return class_name;
    }

    public void setClass_name(String class_name) {
        this.class_name = class_name;
    }

    public String getStu_sex() {
        return stu_sex;
    }

    public void setStu_sex(String stu_sex) {
        this.stu_sex = stu_sex;
    }

    public String getStu_name() {
        return stu_name;
    }

    public void setStu_name(String stu_name) {
        this.stu_name = stu_name;
    }
}

TeacherService类:

package online_select.Guanli;

public class TeacherService {
    String teac_id;
    String teac_name;
    String teac_sex;
    String college;
    String postion;

    public String getPostion() {

        return postion;
    }

    public void setPostion(String postion) {
        this.postion = postion;
    }

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getTeac_sex() {
        return teac_sex;
    }

    public void setTeac_sex(String teac_sex) {
        this.teac_sex = teac_sex;
    }

    public String getTeac_name() {
        return teac_name;
    }

    public void setTeac_name(String teac_name) {
        this.teac_name = teac_name;
    }

    public String getTeac_id() {
        return teac_id;
    }

    public void setTeac_id(String teac_id) {
        this.teac_id = teac_id;
    }
}

Login包:

DBUtil类:

package online_select.Login;

import java.sql.*;

public class DBUtil {

    public static String db_url = "jdbc:mysql://localhost:3306/online_select?useSSL=false&serverTimezone=UTC&characterEncoding=UTF-8";
    public static String db_user = "root";
    public static String db_pass = "131517.a";

    public static Connection getConn () {
        Connection conn = null;

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");//加载驱动
            conn = DriverManager.getConnection(db_url, db_user, db_pass);
            System.out.println("Yes!");
        } catch (Exception e) {
            e.printStackTrace();
        }

        return conn;
    }

    /**
     * 关闭连接
     * @param state
     * @param conn
     */
    public static void close (Statement state, Connection conn) {
        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close (ResultSet rs, Statement state, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (state != null) {
            try {
                state.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }

        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws SQLException {
        Connection conn = getConn();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        String sql ="select * from course";
        pstmt = conn.prepareStatement(sql);
        rs = pstmt.executeQuery();
        if(rs.next()){
            System.out.println("空");
        }else{
            System.out.println("不空");
        }
    }
}

LoginServlet类:

package online_select.Login;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class LoginServlet
 */
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public LoginServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        Select s=new Select();
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("login"))
        {
            String username;
            username=arg0.getParameter("username");
            String password;
            password=arg0.getParameter("password");
            String power;
            power=arg0.getParameter("power");
            int num=Integer.parseInt(power);
            flag=s.select("login", username, password,num);
            Power.setFlag(num);
            if(flag)
            {
                arg0.setAttribute("message","登录成功");
                arg0.getRequestDispatcher("Home.jsp").forward(arg0, arg1);

            }
            else
            {
                arg0.setAttribute("message","账号或密码错误");
                arg0.getRequestDispatcher("Login.jsp").forward(arg0, arg1);
            }


        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

Power类:

package online_select.Login;

public class Power {
    static int flag;

    public static int getFlag() {
        return flag;
    }

    public static void setFlag(int flag) {
        Power.flag = flag;
    }
    static String name;

    public static String getName() {
        return name;
    }

    public static void setName(String name) {
        Power.name = name;
    }
    static String username;

    public static String getUsername() {
        return username;
    }

    public static void setUsername(String username) {
        Power.username = username;
    }



}

Select类

package online_select.Login;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Select {
    public boolean  select(String table,String username,String password,int num)
    {
        boolean f=false;
        Connection conn=DBUtil.getConn();
        Statement state=null;
        try
        {
            state=conn.createStatement();
            String sql="select * from "+table;
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                if(username.equals(rs.getString(1))&&password.equals(rs.getString(2)))
                {
                    Power.setName(rs.getString(4));
                    Power.setUsername(rs.getString(1));
                    System.out.println(Power.getName());
                    f=true;
                }
            }
            rs.close();
            state.close();
            conn.close();

        }
        catch(Exception e)
        {

        }
        return f;
    }

}

Student包:

Change类:

package online_select.Student;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class Change {
    public boolean change(String table,String lie,String lie0,String gai,String biao)
    {
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            String sql="update "+table+" set "+lie+"='"+gai+"' where "+lie0+"='"+biao+"'";
            System.out.println(sql);
            state.executeUpdate(sql);
            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        return true;
    }

}

CourseDao类:

package online_select.Student;

public class CourseDao {
    String course_id;
    String teac_name;
    String teac_id;
    String stu_id;
    String stu_name;

    public String getStu_name() {
        return stu_name;
    }

    public void setStu_name(String stu_name) {
        this.stu_name = stu_name;
    }

    public String getStu_id() {
        return stu_id;
    }

    public void setStu_id(String stu_id) {
        this.stu_id = stu_id;
    }

    public String getTeac_id() {
        return teac_id;
    }

    public void setTeac_id(String teac_id) {
        this.teac_id = teac_id;
    }

    public String getTeac_name() {
        return teac_name;
    }

    public void setTeac_name(String teac_name) {
        this.teac_name = teac_name;
    }

    public String getCourse_id() {
        return course_id;
    }

    public void setCourse_id(String course_id) {
        this.course_id = course_id;
    }
}

CoueseService类:

package online_select.Student;

public class CourseService {
    static String course_id;
    static String couese_name;
    static String teac_id;
    static String teac_name;
    static int ceiling;
    static int existing;

    public static int getExisting() {
        return existing;
    }

    public static void setExisting(int existing) {
        CourseService.existing = existing;
    }

    public static int getCeiling() {
        return ceiling;
    }

    public static void setCeiling(int ceiling) {
        CourseService.ceiling = ceiling;
    }

    public static String getTeac_name() {
        return teac_name;
    }

    public static void setTeac_name(String teac_name) {
        CourseService.teac_name = teac_name;
    }

    public static String getTeac_id() {
        return teac_id;
    }

    public static void setTeac_id(String teac_id) {
        CourseService.teac_id = teac_id;
    }

    public static String getCouese_name() {
        return couese_name;
    }

    public static void setCouese_name(String couese_name) {
        CourseService.couese_name = couese_name;
    }

    public static String getCourse_id() {
        return course_id;
    }

    public static void setCourse_id(String course_id) {
        CourseService.course_id = course_id;
    }
}

SelectServlet类:

package online_select.Student;

import online_select.Login.Power;

import javax.servlet.ServletException;
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.util.List;

@WebServlet("/SelectServlet")
public class SelectServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public SelectServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("submit"))
        {
            List<CourseService> userall = StudentGet.getAll();
            java.util.Collections.reverse(userall);
            arg0.setAttribute("all", userall);
            arg0.getRequestDispatcher("student/Select.jsp").forward(arg0, arg1);
        }
        if(function.equals("select"))
        {
            Change c=new Change();
            CourseDao j=new CourseDao();
            StudentFind f=new StudentFind();
            f.find("student", Power.getName());
            String teac_name;
            teac_name = arg0.getParameter("teac_name");
            j.setTeac_name(teac_name);
            String course_id;
            course_id=arg0.getParameter("course_id");
            j.setCourse_id(course_id);
            String existing;
            existing=arg0.getParameter("existing");
            String teac_id;
            teac_id=arg0.getParameter("teac_id");
            j.setTeac_id(teac_id);
            j.setStu_name(StudentService.getStu_name());
            j.setStu_id(StudentService.getStu_id());
            int num=Integer.parseInt(existing);
            num++;
            System.out.println(num);
            StudentSelect s=new StudentSelect();
            flag=s.select("course",course_id, StudentService.getStu_id());
            if(flag)
            {
                c.change("class", "existing", "course_id", num+"", course_id);
                StudentAdd a=new StudentAdd();
                a.add("course", j);
                arg0.setAttribute("message", "选课成功");
                arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);
            }
            else
            {
                arg0.setAttribute("message", "选课重复");
                arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);
            }
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}

StudentAdd类:

package online_select.Student;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class StudentAdd {
    public boolean add(String table, CourseDao course)
    {
        boolean c=false;
        String sql="insert into "+table+"(course_id,teac_id,teac_name,stu_id,stu_name) values"
                + "('"+course.getCourse_id()+"','"+course.getTeac_id()+"','"+course.getTeac_name()+"','"+course.getStu_id()+"','"+course.getStu_name()+"');";
        System.out.println(sql);
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            int num=state.executeUpdate(sql);
            if(num!=0)
                c=true;


            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }


        return c;

    }
}

StudentChangeServlet类:

package online_select.Student;

import online_select.Login.Power;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class StudentChangeServlet
 */
@WebServlet("/StudentChangeServlet")
public class StudentChangeServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public StudentChangeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("submit"))
        {
            StudentFind f=new StudentFind();
            f.find("student", Power.getName());
            arg0.getRequestDispatcher("student/Change.jsp").forward(arg0, arg1);
        }
        if(function.equals("change"))
        {
            Change c=new Change();
            String stu_name;
            stu_name=arg0.getParameter("stu_name");
            String stu_sex;
            stu_sex=arg0.getParameter("stu_sex");
            String class_name;
            class_name=arg0.getParameter("class_name");
            String college;
            college=arg0.getParameter("college");
            c.change("course", "stu_name", "stu_id", stu_name, StudentService.getStu_id());
            c.change("login", "name", "username", stu_name, Power.getUsername());
            Power.setUsername(stu_name);
            c.change("student", "stu_name", "stu_id", stu_name, StudentService.getStu_id());
            c.change("student", "stu_sex", "stu_id", stu_sex, StudentService.getStu_id());
            c.change("student", "college", "stu_id", class_name, StudentService.getStu_id());
            c.change("student", "class_name", "stu_id", college, StudentService.getStu_id());
            arg0.setAttribute("message", "修改成功");
            arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

StudentFind类:

package online_select.Student;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class StudentFind {
    public boolean  find(String table,String name)
    {
        @SuppressWarnings("unused")
        boolean c;
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try
        {
            state=conn.createStatement();
            String sql="select * from "+table+" where stu_name ='"+name+"'";
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                StudentService.setStu_id(rs.getString(1));
                StudentService.setStu_name(rs.getString(2));
                StudentService.setStu_sex(rs.getString(3));
                StudentService.setClass_name(rs.getString(4));
                StudentService.setCollege(rs.getString(5));
            }
            rs.close();
            state.close();
            conn.close();
            System.out.println("over");

        }
        catch(Exception e)
        {

        }
        return true;
    }
    public void  findclass(String table,String id)
    {
        @SuppressWarnings("unused")
        boolean c;
        Connection conn=DBUtil.getConn();
        Statement state=null;
        try
        {
            state=conn.createStatement();
            String sql="select * from "+table+" where course_id ='"+id+"'";
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                CourseService.setCourse_id(rs.getString(1));
                CourseService.setCouese_name(rs.getString(2));
                CourseService.setTeac_name(rs.getString(4));
                CourseService.setCeiling(rs.getInt(5));
                CourseService.setExisting(rs.getInt(6));
            }
            rs.close();
            state.close();
            conn.close();
            System.out.println("over");

        }
        catch(Exception e)
        {

        }
    }
    public void  findjiaoshi(String table,String id)
    {
        @SuppressWarnings("unused")
        boolean c;
        Connection conn=DBUtil.getConn();
        Statement state=null;
        try
        {
            state=conn.createStatement();
            String sql="select * from "+table+" where teac_id ='"+id+"'";
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                TeacherService.setTeac_id(rs.getString(1));
                TeacherService.setTeac_name(rs.getString(2));
                TeacherService.setTeac_sex(rs.getString(3));
                TeacherService.setCollege(rs.getString(4));
                TeacherService.setPosition(rs.getString(5));
            }
            rs.close();
            state.close();
            conn.close();
            System.out.println("over");

        }
        catch(Exception e)
        {

        }
    }
}

StudentGet类:

package online_select.Student;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class StudentGet {
    @SuppressWarnings("unused")
    public static List<CourseService> getAll()
    {
        List<CourseService> list=new ArrayList<CourseService>();
        Connection conn= DBUtil.getConn();
        PreparedStatement state=null;
        ResultSet rs=null;
        String sql="select * from course";
        try
        {
            state=conn.prepareStatement(sql);
            rs=state.executeQuery();
            while(rs.next())
            {
                if(rs.getInt(5)>rs.getInt(6))
                {
                    CourseService user=new CourseService();
                    user.setCourse_id(rs.getString(1));
                    user.setCouese_name(rs.getString(2));
                    user.setTeac_id(rs.getString(3));
                    user.setTeac_name(rs.getString(4));
                    user.setCeiling(rs.getInt(6));
                    list.add(user);
                }
            }
            rs.close();
            state.close();
            conn.close();
        }
        catch(Exception e)
        {

        }

        if(list!=null) {

            return list;
        }else {

            return null;
        }
    }
    @SuppressWarnings("unused")
    public static List<CourseService> getAll0()
    {
        List<CourseService> list=new ArrayList<CourseService>();
        Connection conn=DBUtil.getConn();
        PreparedStatement state=null;
        ResultSet rs=null;
        String sql="select * from class";
        try
        {
            state=conn.prepareStatement(sql);
            rs=state.executeQuery();
            while(rs.next())
            {
                CourseService user=new CourseService();
                user.setCourse_id(rs.getString(1));
                user.setCouese_name(rs.getString(2));
                user.setTeac_id(rs.getString(3));
                user.setTeac_name(rs.getString(4));
                user.setCeiling(rs.getInt(6));
                list.add(user);
            }
            rs.close();
            state.close();
            conn.close();
        }
        catch(Exception e)
        {

        }

        if(list!=null) {

            return list;
        }else {

            return null;
        }
    }
}

StudentScanCoueseServlet类:

package online_select.Student;

import javax.servlet.ServletException;
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.util.List;

@WebServlet("/StudentScanCourseServlet")
public class StudentScanCourseServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public StudentScanCourseServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("submit"))
        {
            List<CourseService> userall = StudentGet.getAll0();
            java.util.Collections.reverse(userall);
            arg0.setAttribute("all", userall);
            arg0.getRequestDispatcher("student/Scan.jsp").forward(arg0, arg1);
        }
        if(function.equals("course"))
        {
            String course_id=arg0.getParameter("course_id");
            StudentFind f=new StudentFind();
            f.findclass("class", course_id);
            arg0.getRequestDispatcher("student/Course.jsp").forward(arg0, arg1);

        }
        if(function.equals("teacher"))
        {
            String teac_id;
            teac_id=arg0.getParameter("teac_id");
            StudentFind f=new StudentFind();
            f.findjiaoshi("teacher", teac_id);
            arg0.getRequestDispatcher("student/Teacher.jsp").forward(arg0, arg1);
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}

StudentSelect类:

package online_select.Student;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class StudentSelect {
    public boolean  select(String table,String course_id,String stu_id)
    {
        boolean c=true;
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try
        {
            state=conn.createStatement();
            String sql="select * from "+table;
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                if(course_id.equals(rs.getString(1))&&stu_id.equals(rs.getString(4)))
                {
                    c=false;
                }
            }
            rs.close();
            state.close();
            conn.close();

        }
        catch(Exception e)
        {

        }
        return c;
    }
}

StudentService类:

package online_select.Student;

public class StudentService {
    static String stu_id;
    static String stu_name;
    static String stu_sex;
    static String class_name;
    static String college;

    public static String getCollege() {
        return college;
    }

    public static void setCollege(String college) {
        StudentService.college = college;
    }

    public static String getClass_name() {
        return class_name;
    }

    public static void setClass_name(String class_name) {
        StudentService.class_name = class_name;
    }

    public static String getStu_sex() {
        return stu_sex;
    }

    public static void setStu_sex(String stu_sex) {
        StudentService.stu_sex = stu_sex;
    }

    public static String getStu_name() {
        return stu_name;
    }

    public static void setStu_name(String stu_name) {
        StudentService.stu_name = stu_name;
    }

    public static String getStu_id() {
        return stu_id;
    }

    public static void setStu_id(String stu_id) {
        StudentService.stu_id = stu_id;
    }
}

TeacherService类:

package online_select.Student;

public class TeacherService {
    static String teac_id;
    static String teac_name;
    static String teac_sex;
    static String college;
    static String position;


    public static String getTeac_id() {
        return teac_id;
    }

    public static void setTeac_id(String teac_id) {
        TeacherService.teac_id = teac_id;
    }

    public static String getTeac_name() {
        return teac_name;
    }

    public static void setTeac_name(String teac_name) {
        TeacherService.teac_name = teac_name;
    }



    public static String getTeac_sex() {
        return teac_sex;
    }

    public static void setTeac_sex(String teac_sex) {
        TeacherService.teac_sex = teac_sex;
    }


    public static String getCollege() {
        return college;
    }
    public static void setCollege(String college) {
        TeacherService.college = college;
    }


    public static String getPosition() {
        return position;
    }

    public static void setPosition(String position) {
        TeacherService.position = position;
    }
}

Teacher包:

ClassService类:

package online_select.Teacher;

public class ClassService {
    String course_id;
    String course_name;
    int teac_id;
    String teac_name;
    int ceiling;
    int existing;

    public int getExisting() {
        return existing;
    }

    public void setExisting(int existing) {
        this.existing = existing;
    }

    public int getCeiling() {
        return ceiling;
    }

    public void setCeiling(int ceiling) {
        this.ceiling = ceiling;
    }

    public String getTeac_name() {
        return teac_name;
    }

    public void setTeac_name(String teac_name) {
        this.teac_name = teac_name;
    }

    public int getTeac_id() {
        return teac_id;
    }

    public void setTeac_id(int teac_id) {
        this.teac_id = teac_id;
    }

    public String getCourse_name() {
        return course_name;
    }

    public void setCourse_name(String course_name) {
        this.course_name = course_name;
    }

    public String getCourse_id() {
        return course_id;
    }

    public void setCourse_id(String course_id) {
        this.course_id = course_id;
    }
}

ClassServlet类:

package online_select.Teacher;

import online_select.Login.Power;
import online_select.Login.Select;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class ClassServlet
 */
@WebServlet("/ClassServlet")
public class ClassServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ClassServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        @SuppressWarnings("unused")
        Select s=new Select();
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("submit"))
        {
            TeacherFind f=new TeacherFind();
            f.find("teacher", Power.getName());
            TeacherAdd a=new TeacherAdd();
            ClassService ks=new ClassService();
            String course_id;
            course_id=arg0.getParameter("course_id");
            ks.setCourse_id(course_id);
            String course_name;
            course_name=arg0.getParameter("course_name");
            ks.setCourse_name(course_name);
            String teac_name;
            teac_name=Power.getName();
            String teac_id;
            teac_id= TeacherService.getTeac_id();
            ks.setTeac_id(Integer.parseInt(teac_id));
            ks.setTeac_name(teac_name);
            String ceiling;
            ceiling=arg0.getParameter("ceiling");
            int num=Integer.parseInt(ceiling);
            ks.setCeiling(num);
            ks.setExisting(0);
            a.add("class", ks);
            arg0.setAttribute("message", "添加成功");
            arg0.getRequestDispatcher("teacher/AddCourse.jsp").forward(arg0, arg1);




        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

StudentDao类:

package online_select.Teacher;

public class StudentDao {
    String stu_id;
    String stu_name;

    public String getStu_name() {
        return stu_name;
    }

    public void setStu_name(String stu_name) {
        this.stu_name = stu_name;
    }

    public String getStu_id() {
        return stu_id;
    }

    public void setStu_id(String stu_id) {
        this.stu_id = stu_id;
    }
}

TeacherAdd类:

package online_select.Teacher;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class TeacherAdd {
    public boolean add(String table, ClassService classService)
    {
        boolean c=false;
        String sql="insert into "+table+"(course_id,course_name,teac_id,teac_name,ceiling,existing) values"
                + "('"+classService.getCourse_id()+"','"+classService.getCourse_name()+"','"+classService.getTeac_id()+"','"+classService.getTeac_name()+"','"+classService.getCeiling()+"','"+classService.getExisting()+"');";
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            int num=state.executeUpdate(sql);
            if(num!=0)
                c=true;


            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            //e.printStackTrace();
        }


        return c;

    }

}

TeacherChange类:

package online_select.Teacher;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class TeacherChange {
    public boolean change(String table,String lie,String lie0,String gai,String biao)
    {
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try {
            state=conn.createStatement();
            String sql="update "+table+" set "+lie+"='"+gai+"' where "+lie0+"='"+biao+"'";
            System.out.println(sql);
            state.executeUpdate(sql);
            state.close();
            conn.close();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


        return true;
    }
}

TeacherCHangeServlet类:

package online_select.Teacher;

import online_select.Login.Power;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class TeacherChangeServlet
 */
@WebServlet("/TeacherChangeServlet")
public class TeacherChangeServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public TeacherChangeServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("submit"))
        {
            TeacherFind f=new TeacherFind();
            f.find("teacher", Power.getName());
            arg0.getRequestDispatcher("teacher/Change.jsp").forward(arg0, arg1);
        }
        if(function.equals("change"))
        {
            TeacherChange c=new TeacherChange();
            String teac_name;
            teac_name=arg0.getParameter("teac_name");
            String teac_sex;
            teac_sex=arg0.getParameter("teac_sex");
            String college;
            college=arg0.getParameter("college");
            String position;
            position=arg0.getParameter("position");
            c.change("class", "teac_name", "teac_id",teac_name, TeacherService.getTeac_id());
            c.change("login", "name", "username", teac_name, Power.getUsername());
            Power.setUsername(teac_name);
            c.change("teacher", "teac_name", "teac_id", teac_name, TeacherService.getTeac_id());
            c.change("teacher", "teac_sex", "teac_id", teac_sex, TeacherService.getTeac_id());
            c.change("teacher", "college", "teac_id", college, TeacherService.getTeac_id());
            c.change("teacher", "position", "teac_id", position, TeacherService.getTeac_id());
            arg0.setAttribute("message", "修改成功");
            arg0.getRequestDispatcher("Right.jsp").forward(arg0, arg1);
        }
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }

}

TeacherFind类:

package online_select.Teacher;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class TeacherFind {
    public boolean  find(String table,String name)
    {
        @SuppressWarnings("unused")
        boolean c;
        Connection conn= DBUtil.getConn();
        Statement state=null;
        try
        {

            state=conn.createStatement();
            String sql="select * from "+table+" where teac_name ='"+name+"'";
            ResultSet rs=state.executeQuery(sql);
            while(rs.next())
            {
                TeacherService.setTeac_id(rs.getString(1));
                TeacherService.setTeac_name(rs.getString(2));
                TeacherService.setTeac_sex(rs.getString(3));
                TeacherService.setCollege(rs.getString(4));
                TeacherService.setPosition(rs.getString(5));
            }
            rs.close();
            state.close();
            conn.close();
            System.out.println("over");

        }
        catch(Exception e)
        {

        }
        return true;
    }
}

TeacherGet类:

package online_select.Teacher;

import online_select.Login.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class TeacherGet {
    @SuppressWarnings("unused")
    public static List<ClassService> getAll(String id)
    {
        List<ClassService> list=new ArrayList<ClassService>();
        Connection conn= DBUtil.getConn();
        PreparedStatement state=null;
        ResultSet rs=null;
        String sql="select * from course where teac_id ='"+id+"'";
        try
        {
            state=conn.prepareStatement(sql);
            rs=state.executeQuery();
            while(rs.next())
            {

                ClassService user=new ClassService();
                user.setCourse_id(rs.getString(1));
                user.setCourse_name(rs.getString(2));
                user.setTeac_id(Integer.parseInt(rs.getString(3)));
                user.setTeac_name(rs.getString(4));
                user.setExisting(rs.getInt(6));
                list.add(user);
            }
            rs.close();
            state.close();
            conn.close();
        }
        catch(Exception e)
        {

        }

        if(list!=null) {

            return list;
        }else {

            return null;
        }
    }
    @SuppressWarnings("unused")
    public static List<StudentDao> getAllxs(String id)
    {
        List<StudentDao> list=new ArrayList<StudentDao>();
        Connection conn=DBUtil.getConn();
        PreparedStatement state=null;
        ResultSet rs=null;
        String sql="select * from course";
        try
        {
            state=conn.prepareStatement(sql);
            rs=state.executeQuery();
            while(rs.next())
            {
                if(rs.getString(1).equals(id))
                {
                    StudentDao user=new StudentDao();
                    user.setStu_name(rs.getString(4));
                    user.setStu_id(rs.getString(3));
                    list.add(user);
                }
            }
            rs.close();
            state.close();
            conn.close();
        }
        catch(Exception e)
        {

        }

        if(list!=null) {

            return list;
        }else {

            return null;
        }
    }
}

TeacherScanServlet类:

package online_select.Teacher;

import online_select.Login.Select;

import javax.servlet.ServletException;
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.util.List;

/**
 * Servlet implementation class TeacherScanServlet
 */
@WebServlet("/TeacherScanServlet")
public class TeacherScanServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public TeacherScanServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("Served at: ").append(request.getContextPath());
    }
    protected void service(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException
    {
        @SuppressWarnings("unused")
        Select s=new Select();
        arg0.setCharacterEncoding("utf-8");
        arg1.setCharacterEncoding("utf-8");
        @SuppressWarnings("unused")
        boolean flag;
        String function=arg0.getParameter("method");
        if(function.equals("Scan"))
        {
            List<ClassService> userall = TeacherGet.getAll(TeacherService.getTeac_id());
            java.util.Collections.reverse(userall);
            arg0.setAttribute("all", userall);
            arg0.getRequestDispatcher("teacher/Scan.jsp").forward(arg0, arg1);
        }
        if(function.equals("change"))
        {
            String course_id;
            course_id=arg0.getParameter("course_id");
            List<StudentDao> userall = TeacherGet.getAllxs(course_id);
            java.util.Collections.reverse(userall);
            arg0.setAttribute("all", userall);
            arg0.getRequestDispatcher("teacher/Change.jsp").forward(arg0, arg1);
        }
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}

TeacherService类:

package online_select.Teacher;

public class TeacherService {
    static String  teac_id;
    static String teac_name;
    static String teac_sex;
    static String college;
    static String position;

    public static String getTeac_id() {
        return teac_id;
    }

    public static void setTeac_id(String teac_id) {
        TeacherService.teac_id = teac_id;
    }

    public static String getCollege() {
        return college;
    }

    public static void setCollege(String college) {
        TeacherService.college = college;
    }

    public static String getTeac_sex() {
        return teac_sex;
    }

    public static void setTeac_sex(String teac_sex) {
        TeacherService.teac_sex = teac_sex;
    }

    public static String getTeac_name() {
        return teac_name;
    }

    public static void setTeac_name(String teac_name) {
        TeacherService.teac_name = teac_name;
    }

    public static String getPosition() {
        return position;
    }

    public static void setPosition(String position) {
        TeacherService.position = position;
    }
}

JSP代码:

Guanli包:

AddStudent.jsp

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body align="center">
<form action="${pageContext.request.contextPath}/RegisterServlet?method=student"method="post">
    <table algin="center">
        <tr>
            <td>账号</td>
            <td><input type="text"name="username"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password"name="password"></td>
        </tr>
        <tr>
            <td>学号:</td>
            <td><input type="text"name="stu_id"></td>
        </tr>
        <tr>
            <td>姓名:</td>
            <td><input type="text"name="stu_name"></td>
        </tr>
        <tr>
            <td>性别:</td>
            <td><input type="text"name="stu_sex"></td>
        </tr>
        <tr>
            <td>班级:</td>
            <td><input type="text"name="class_name"></td>
        </tr>
        <tr>
            <td>专业:</td>
            <td><input type="text"name="college"></td>
        </tr>
    </table>
    <p><input type="submit"value="确定添加"style="width:100px;height:30px;background-color:#bdd7f2;"></p>
</form>

</body>
</html>

AddTeacher.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body align="center">
<form action="${pageContext.request.contextPath}/RegisterServlet?method=teacher"method="post">
    <table algin="center">
        <tr>
            <td>账号</td>
            <td><input type="text"name="username"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password"name="password"></td>
        </tr>
        <tr>
            <td>工号:</td>
            <td><input type="text"name="stu_id"></td>
        </tr>
        <tr>
            <td>姓名:</td>
            <td><input type="text"name=stu_name"></td>
        </tr>
        <tr>
            <td>性别:</td>
            <td><input type="text"name="stu_sex"></td>
        </tr>
        <tr>
            <td>所在学院:</td>
            <td><input type="text"name="college"></td>
        </tr>
        <tr>
            <td>职称:</td>
            <td><input type="text"name="position"></td>
        </tr>
    </table>
    <p><input type="submit"value="确定添加"style="width:100px;height:30px;background-color:#bdd7f2;"></p>
</form>

</body>
</html>

Student包

Change.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ page language="java" import="online_select.Student.StudentService"%>
    <title>Title</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body>
<form action="${pageContext.request.contextPath}/StudentChangeServlet?method=change"method="post">
    <table>
        <tr>
            <td>学号</td>
            <td><%=StudentService.getStu_id() %></td>
        </tr>
        <tr>
            <td>姓名</td>
            <td><input type="text"name="stu_name"value=<%=StudentService.getStu_name() %>></td>
        </tr>
        <tr>
            <td>性别</td>
            <td><input type="text"name="stu_sex"value=<%=StudentService.getStu_sex() %>></td>
        </tr>
        <tr>
            <td>班级</td>
            <td><input type="text"name="class_name"value=<%=StudentService.getClass_name() %>></td>
        </tr>
        <tr>
            <td>专业</td>
            <td><input type="text"name="college"value=<%=StudentService.getCollege() %>></td>
        </tr>
    </table>
    <p><input type="submit"value="确定添加"style="width:100px;height:30px;background-color:#bdd7f2;"></p>
</form>
</body>
</html>

Course.jsp:

<%@ page import="online_select.Student.CourseService" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@ page language="java" import="online_select.Student.CourseService"%>
</head>
<body style="margin-top:100px;">
<table align="center">
    <tr>
        <td>课程编号:</td>
        <td><%=CourseService.getCourse_id()%></td>
    </tr>
    <tr>
        <td>课程名称:</td>
        <td><%=CourseService.getCouese_name() %></td>
    </tr>
    <tr>
        <td>任课教师:</td>
        <td><%=CourseService.getTeac_name() %></td>
    </tr>
    <tr>
        <td>课程容量:</td>
        <td><%=CourseService.getCeiling()%></td>
    </tr>
    <tr>
        <td>现有人数:</td>
        <td><%=CourseService.getExisting()%></td>
    </tr>
</table>
</body>
</html>

Scan.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table align="center" border="1">
    <tr>
        <td>课程名称</td>
        <td>课程编号</td>
        <td>任课教师</td>

    </tr>

    <c:forEach  var="stu" items="${all}" >
        <tr>
            <td><a href="StudentScanCourseServlet?method=course&course_id=${stu.getCourse() }">${stu.getCourse() }</a></td>
            <td>${stu.getKechengbianhao() }</td>
            <td><a href="StudentScanCourseServlet?method=teacher&teac_id=${stu.getTeac_id() }">${stu.getTeac_name() }</a></td>
        </tr>
    </c:forEach>

</table>
</body>
</html>

Select.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table align="center" border="1">
    <tr>
        <td>课程名称</td>
        <td>课程编号</td>
        <td>任课教师</td>
        <td>操作</td>
    </tr>

    <c:forEach  var="stu" items="${all}" >
        <tr>
            <td>${stu.getCourse_name() }</td>
            <td>${stu.getCourse_id() }</td>
            <td>${stu.getTeac_name() }</td>
            <td><a href="${pageContext.request.contextPath}/SelectServlet?method=select&course_id=${stu.getCourse_id()}&existing=${stu.getExisting()}&teac_name=${stu.getTeac_name()}&teac_id=${stu.getTeac_id()}">选课</a></td>
        </tr>
    </c:forEach>

</table>
</body>
</html>

Teacher.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@ page language="java" import="online_select.Student.TeacherService"%>
</head>
<body style="margin-top:100px">
<table align="center">
    <tr>
        <td>工号:</td>
        <td><%=TeacherService.getTeac_id() %></td>
    </tr>
    <tr>
        <td>任课教师</td>
        <td><%=TeacherService.getTeac_name() %></td>
    </tr>
    <tr>
        <td>教师性别</td>
        <td><%=TeacherService.getTeac_sex()%></td>
    </tr>
    <tr>
        <td>学院:</td>
        <td><%=TeacherService.getCollege() %></td>
    </tr>
    <tr>
        <td>职称</td>
        <td><%=TeacherService.getPosition() %></td>
    </tr>
</table>
</body>
</html>

Teacher包:

AddCourse.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body>
<form action="${pageContext.request.contextPath}/ClassServlet?method=submit"method="post">
    <table align="center">
        <tr>
            <td>课程编号</td>
            <td><input type="text"name="course_id"></td>
        </tr>
        <tr>
            <td>课程名称</td>
            <td><input type="text"name="course_name"></td>
        </tr>
        <tr>
            <td>课程人数</td>
            <td><input type="text"name="ceiling"></td>
        </tr>
    </table>
    <p><input type="submit"value="确定添加"style="width:100px;height:30px;background-color:#bdd7f2;"></p>
</form>
</body>
</html>

Change.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9: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>
<meta charset="utf-8">
<%@ page language="java" import="online_select.Teacher.TeacherService"%>
<title>Insert title here</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body>
<form action="${pageContext.request.contextPath}/TeacherChangeServlet?method=change"method="post">
    <table>
        <tr>
            <td>工号</td>
            <td><%=TeacherService.getTeac_id() %></td>
        </tr>
        <tr>
            <td>姓名</td>
            <td><input type="text"name="teac_name"value=<%=TeacherService.getTeac_name() %>></td>
        </tr>
        <tr>
            <td>性别</td>
            <td><input type="text"name="teac_id"value=<%=TeacherService.getTeac_sex() %>></td>
        </tr>
        <tr>
            <td>所在学院</td>
            <td><input type="text"name="college"value=<%=TeacherService.getCollege() %>></td>
        </tr>
        <tr>
            <td>职称</td>
            <td><input type="text"name="position"value=<%=TeacherService.getPosition() %>></td>
        </tr>
    </table>
    <p><input type="submit"value="确定添加"style="width:100px;height:30px;background-color:#bdd7f2;"></p>
</form>
</body>
</html>

Scan.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table align="center" border="1">
    <tr>
        <td>课程名称</td>
        <td>课程编号</td>
        <td>现有人数</td>
    </tr>

    <c:forEach  var="stu" items="${all}" >
        <tr>
            <td><a href="${pageContext.request.contextPath}/TeacherScanService?method=Scan&course_id=${stu.getCourse_id()}&existing=${stu.getExisting()}">${stu.getCourse_name()}</a></td>
            <td>${stu.getCourse_id() }</td>
            <td>${stu.getExisting() }</td>
        </tr>
    </c:forEach>

</table>
</body>
</html>

SrudentInfo.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/18
  Time: 9:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table align="center" border="1">
    <tr>
        <td>姓名</td>
        <td>学号</td>
    </tr>

    <c:forEach  var="stu" items="${all}" >
        <tr>
            <td>${stu.getStu_name() }</td>
            <td>${stu.getStu_id() }</td>
        </tr>
    </c:forEach>

</table>
</body>
</html>

登录界面以及主界面jsp代码:

Home.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/17
  Time: 10:48
  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>
    <%
        //
        //接收servlet传过来的那个message的参数
        //alert是js语句中的弹出警示框,也就是弹出message中的参数
        Object message=request.getAttribute("message");
        if(!(message==null||message.equals("")))
        {
    %>
    <script type="text/javascript">alert('<%=message%>')</script>
    <%
        }
    %>
    <iframeset rows="15%,*">
        <iframe src="Top.jsp" name="top"></iframe>
        <iframeset cols="25%,*">
            <iframe src="Left.jsp" name="left"></iframe>
            <iframe src="Right.jsp" name="right"></iframe>
        </iframeset>
    </iframeset>
</body>
</html>

Left.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/17
  Time: 10:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<head>
    <title>Title</title>
    <style type="text/css">
        body {
            margin: 0;
            padding: 0;
            font-size: 12px;
            font-family: "Microsoft Yahei", Verdana, Arial, Helvetica, sans-serif
        }
        .leftMenu {
            min-width:220px;
            width:268px;
            margin:40px auto 0 auto;
        }
        .menu {
            border: #bdd7f2 1px solid;
            border-top: #0080c4 4px solid;
            border-bottom: #0080c4 4px solid;
            background: #f4f9ff repeat-y right;
            margin-left: 10px;
        }
        .menu .ListTitle {

            border-bottom: 1px #98c9ee solid;
            display: block;
            text-align: center;
            /*position: relative;*/
            height: 38px;
            line-height: 38px;
            cursor: pointer;
            /*+min-width:220px;*/

        +width:100%;
        }
        .ListTitlePanel {
            position: relative;
        }
        .leftbgbt {
            position: absolute;
            background: no-repeat;
            width: 11px;
            height: 52px;
            left: -11px;
            top: -4px;
        }
        /*.leftbgbt {
            float:left;
            background: no-repeat;
            width: 11px;
            height: 52px;
            left: 0px;
            top: 0px;
            zoom:1;
            z-index:200px;
        }
        */
        .leftbgbt2 {
            position: absolute;
            background: no-repeat;
            width: 11px;
            height: 48px;
            left: -11px;
            top: -1px;
        }
        .menuList {
            display: block;
            height: auto;
        }
        .menuList div {
            height: 28px;
            line-height: 24px;
            border-bottom: 1px #98c9ee dotted;
        }
        .menuList div a {
            display: block;
            background: #fff;
            line-height: 28px;
            height: 28px;

            color: #185697;
            text-decoration: none;
        }
        .menuList div a:hover {
            color: #f30;
            background: #0080c4;
            color: #fff;
        }
    </style>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    int message=online_select.Login.Power.getFlag();
%>
<body style="margin-top:-30px">
<input type="hidden" name="message"value=<%=message %>>
<div class="leftMenu">
    <div class="menu">
        <div class="menuParent">
            <div class="ListTitlePanel">
                <div class="ListTitle">
                    <h1><strong>管理</strong></h1>
                    <div class="leftbgbt2"> </div>
                </div>
            </div>
            <div class="menuList" style="text-align:center">
                <%
                    if(message==0)
                    {
                %>
                <div> <a href="Guanli/AddTeacher.jsp" target="right">添加教师</a></div>
                <div> <a href="Guanli/AddStudent.jsp" target="right">添加学生</a></div>
                <%
                    }
                %>
                <%
                    if(message==1)
                    {
                %>
                <div> <a href="Teacher/AddCourse.jsp" target="right">添加课程</a></div>
                <div> <a href="${pageContext.request.contextPath}/online_select.Teacher.TeacherChangeServlet?method=submit" target="right">修改信息</a></div>
                <div> <a href="${pageContext.request.contextPath}/online_select.Teacher.TeacherScanServlet?method=Scan" target="right">浏览选课</a></div>
                <%
                    }
                %>
                <%
                    if(message==2)
                    {
                %>
                <div> <a href="${pageContext.request.contextPath}/online_select.Student.SelectServlet?method=submit" target="right">选课</a></div>
                <div> <a href="${pageContext.request.contextPath}/online_select.Student.StudentChangeServlet?method=submit" target="right">修改信息</a></div>
                <div> <a href="${pageContext.request.contextPath}/online_select.Student.StudentScanCourseServlet?method=submit" target="right">浏览课程</a></div>
                <%
                    }
                %>
            </div>
        </div>
    </div>
</body>
</html>

Login.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/17
  Time: 10:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body style="margin-top:150px">
<form action="LoginServlet?method=login"method="post">
    <table align="center">
        <tr>
            <td>账号:</td>
            <td><input type="text"name="username"style="width:200px;height:24px;"></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><input type="password"name="password"style="width:200px;height:24px;"></td>
        </tr>
        <tr>
            <td>身份:</td>
            <td>
                <select name="power" style="width:200px;height:35px;">
                    <option value="0">管理员</option>
                    <option value="1">教师</option>
                    <option value="2">学生</option>
                </select>
            </td>
        </tr>
    </table>
    <p><input type="submit" value="登录"style="width:120px;height:35px;margin-left:40%;background-color:#bdd7f2"></p>
</form>

</body>
</html>

Right.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/17
  Time: 10:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<%
    //
    //接收servlet传过来的那个message的参数
    //alert是js语句中的弹出警示框,也就是弹出message中的参数
    Object message=request.getAttribute("message");
    if(!(message==null||message.equals("")))
    {
%>
<script type="text/javascript">alert('<%=message%>')</script>
<%
    }
%>
<body>

</body>
</html>

Top.jsp:

<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2022/3/17
  Time: 10:48
  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 style="background-color:#bdd7f2;margin-top:-15px">
<h1 align="center">流转系统</h1>
<strong><a href="Home.jsp" target="_parent" style="text-decoration:none;margin-left:80%">首 页<a href="Login.jsp" target="_parent" style="text-decoration:none">退出</a></strong>
</body>
</html>

数据库文件:

/*
 Navicat Premium Data Transfer

 Source Server         : homework
 Source Server Type    : MySQL
 Source Server Version : 80025
 Source Host           : localhost:3306
 Source Schema         : online_select

 Target Server Type    : MySQL
 Target Server Version : 80025
 File Encoding         : 65001

 Date: 05/04/2022 23:26:59
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for class
-- ----------------------------
DROP TABLE IF EXISTS `class`;
CREATE TABLE `class`  (
  `course_id` int(0) NOT NULL AUTO_INCREMENT,
  `course_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `teac_id` int(0) NULL DEFAULT NULL,
  `teac_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `ceiling` int(0) NULL DEFAULT NULL,
  `existing` int(0) NULL DEFAULT NULL,
  PRIMARY KEY (`course_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of class
-- ----------------------------
INSERT INTO `class` VALUES (1, 'jisuanji', 1, 'kcb', 50, 46);

-- ----------------------------
-- Table structure for course
-- ----------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course`  (
  `course_id` int(0) NOT NULL,
  `teac_id` int(0) NULL DEFAULT NULL,
  `teac_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `stu_id` int(0) NULL DEFAULT NULL,
  `stu_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`course_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course
-- ----------------------------
INSERT INTO `course` VALUES (1, 1, 'kcb', 1, 'kcb');

-- ----------------------------
-- Table structure for login
-- ----------------------------
DROP TABLE IF EXISTS `login`;
CREATE TABLE `login`  (
  `username` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `password` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `power` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `name` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of login
-- ----------------------------
INSERT INTO `login` VALUES ('kcb', '123', '0', 'kcb');
INSERT INTO `login` VALUES ('zr', '123', '2', 'zr');
INSERT INTO `login` VALUES ('hhb', '123', '1', 'hhb');
INSERT INTO `login` VALUES ('kcb', '123', '1', 'kcb');
INSERT INTO `login` VALUES ('zr', '123', '1', 'zr');
INSERT INTO `login` VALUES ('kcb', '123', '2', 'kcb');
INSERT INTO `login` VALUES ('hhb', '123', '2', 'hhb');
INSERT INTO `login` VALUES ('gmh', '123', '1', 'gmh');

-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student`  (
  `stu_id` int(0) NOT NULL,
  `stu_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `stu_sex` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `class_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `college` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`stu_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES (1, 'kcb', '男', '计算机', '计算机');

-- ----------------------------
-- Table structure for teacher
-- ----------------------------
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher`  (
  `teac_id` int(0) NOT NULL,
  `teac_name` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `teac_sex` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `college` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `position` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`teac_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of teacher
-- ----------------------------
INSERT INTO `teacher` VALUES (1, 'kcb', '男', '计算机', 'jisuanji');

SET FOREIGN_KEY_CHECKS = 1;

运行后的界面:

登录界面:

管理员首页:

教师首页:

学生首页:

添加教师界面 

 

添加学生界面:

添加课程界面:

修改教师信息界面:

修改学生信息界面:

教师浏览选课界面:

学生浏览选课界面:

学生选课界面:

课程信息界面:

任课教师信息界面 :

选课人员信息界面: