基于javaweb+mysql的jsp+servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

基于javaweb+mysql的jsp+servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet在线学生选课管理系统(java+jsp+bootstrap+jquery+servlet+mysql)

项目介绍

管理员角色包含以下功能: 管理员登录,学生管理,教师管理,班级管理,添加班级,添加教师,添加学生,课程管理,添加课程,系统用户管理,添加用户,修改密码等功能。

教师角色包含以下功能: 教师登录,选课管理,添加选课学生,成绩管理,添加成绩,查看学生信息,查看班级信息,查看个人档案,修改密码等功能。

学生角色包含以下功能: 学生登录,选课管理,成绩查看,查看个人档案,修改密码等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目

技术栈

  1. 后端:servlet 2. 前端:JSP+bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中db.properties与spring-mybatis.xml配置文件中的数据库配置改为自己的配置; 注:在spring-mybatis.xml没有将db.properties的数据同步过去的情况下修改; 4. 运行项目,输入localhost:8080/chaoshi 登录 注:tomcat中配置项目路径必须为/chaoshi,前端代码中已写死,否则会报错;
            {
                s1 = m_application.getRealPath(s1);
                if(s1.endsWith(s3))
                {
                    s1 = s1 + s2;
                }
                else
                {
                    s1 = s1 + s3 + s2;
                }
                return s1;
            }
            if(flag)
            {
                if(m_denyPhysicalPath)
                {
                    throw new IllegalArgumentException("Physical path is denied (1125).");
                }
                else
                {
                    return s;
                }
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        if(i == 1)
        {
            if(isVirtual(s1))
            {
                s1 = m_application.getRealPath(s1);
                if(s1.endsWith(s3))
                {
                    s1 = s1 + s2;
                }
                else
                {
                    s1 = s1 + s3 + s2;
                }
                return s1;
            }
            if(flag)
            {
                throw new IllegalArgumentException("The path is not a virtual path.");
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        if(i == 2)
        while((long)k < l)
        {
            int j = fileinputstream.read(abyte0,0,i);
            k += j;
            m_response.getOutputStream().write(abyte0,0,j);
        }
        fileinputstream.close();
    }

    public void downloadField(ResultSet resultset,String s,String s1,String s2) throws ServletException,IOException,SQLException
    {
        if(resultset == null)
        {
            throw new IllegalArgumentException("The RecordSet cannot be null (1045).");
        }
        if(s == null)
        {
            throw new IllegalArgumentException("The columnName cannot be null (1050).");
        }
        if(s.length() == 0)
        {
            throw new IllegalArgumentException("The columnName cannot be empty (1055).");
        }
        byte abyte0[] = resultset.getBytes(s);
        if(s1 == null)
        {
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
            if(s1.length() == 0)
            {
                m_response.setContentType("application/x-msdownload");
            }
            else
            {
                m_response.setContentType(s1);
            }
        }
        m_response.setContentLength(abyte0.length);
        if(s2 == null)
        {
            m_response.setHeader("Content-Disposition","attachment;");
        }
        else
		String newpwd = request.getParameter("newpwd");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		String sql = "";
		String str = "";
		
		HttpSession  session = request.getSession();
		ArrayList adminlogin = (ArrayList)session.getAttribute("adminlogin");
		String shenfen = (String)session.getAttribute("shenfen");
		
		if(mark != null && mark.equals("password")){
			str = "/"+shenfen+"/modifypwd.jsp";
			sql = "update "+shenfen+" set pwd='"+newpwd+"' where id="+adminlogin.get(0);
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "密码修改成功!");
			adminlogin.set(2, newpwd);
		}
		if(mark != null && mark.equals("insert")){
			str = "/admin/adminlist.jsp";
			sql = "insert into admin(name,pwd,shenfen) values('"+name+"','"+pwd+"','admin')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/addadmin.jsp";
				request.setAttribute("message", "用户名重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		request.getRequestDispatcher(str).forward(request, response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
            {
                if(j == k - 1)
                {
                    m_endData = ((i - k) + 1) - 3;
                    break;
                }
                i++;
                j++;
            }
            else
            {
                i++;
                j = 0;
            }
        }
        m_currentIndex = m_endData + k + 3;
    }

    private String getDataHeader()
    {
        //boolean flag = false;
        int i = m_currentIndex;
        int j = 0;
        for(boolean flag1 = false;!flag1;)
        {
            if(m_binArray[m_currentIndex] == 13 && m_binArray[m_currentIndex + 2] == 13)
            {
                flag1 = true;
                j = m_currentIndex - 1;
                m_currentIndex = m_currentIndex + 2;
            }
            else
            {
                m_currentIndex++;
            }
        }

        String s = new String(m_binArray,i,(j - i) + 1);
        return s;
    }

    private String getFileName(String s)
    {
        //String s1 = ""; // = new String();
        //String s2 = ""; // = new String();
        //boolean flag = false;
        //boolean flag1 = false;
        //boolean flag2 = false;
        int i = 0;
        i = s.lastIndexOf('/');
        if(i != -1)
        {
            return s.substring(i + 1,s.length());

public class UserLoginServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public UserLoginServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
        if(s.lastIndexOf('.') > 0)
        {
            return s1;
        }
        else
        {
            return "";
        }
    }

    private String getContentType(String s)
    {
        String s1 = ""; // = new String();
        String s2 = ""; // = new String();
        int i = 0;
        //boolean flag = false;
        s1 = "Content-Type:";
        i = s.indexOf(s1) + s1.length();
        if(i != -1)
        {
            int j = s.length();
            s2 = s.substring(i,j);
        }
        return s2;
    }

    private String getTypeMIME(String s)
    {
        //String s1 = new String();
        int i = 0;
        i = s.indexOf("/");
        if(i != -1)
        {
            return s.substring(1,i);
        }
        else
        {
            return s;
        }
    }
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		String banji = request.getParameter("banji");
		String xuehao = request.getParameter("xuehao");
		String zhiwu = request.getParameter("zhiwu");
		String zhenname = request.getParameter("zhenname");
		String sex = request.getParameter("sex");
		String shengri = request.getParameter("shengri");
		String zuohao = request.getParameter("zuohao");
		String shenfenzheng = request.getParameter("shenfenzheng");
		String minzu = request.getParameter("minzu");
		String jiguan = request.getParameter("jiguan");
		String hukou = request.getParameter("hukou");
		String address = request.getParameter("address");
		String phone = request.getParameter("phone");
		String email = request.getParameter("email");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/xuesheng_list.jsp";
			sql = "insert into xuesheng(name,pwd,banji,xuehao,zhiwu,zhenname,sex,shengri,zuohao,shenfenzheng,minzu,jiguan,hukou,address,phone,email,beizhu,shenfen) values('"+name+"','"+pwd+"','"+banji+"','"+xuehao+"','"+zhiwu+"','"+zhenname+"','"+sex+"','"+shengri+"','"+zuohao+"','"+shenfenzheng+"','"+minzu+"','"+jiguan+"','"+hukou+"','"+address+"','"+phone+"','"+email+"','"+beizhu+"','xuesheng')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/xuesheng.jsp?mark="+mark;
				request.setAttribute("message", "用户名或学号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/xuesheng_list.jsp";
			sql = "update xuesheng set banji='"+banji+"',xuehao='"+xuehao+"',zhiwu='"+zhiwu+"',zhenname='"+zhenname+"',sex='"+sex+"',shengri='"+shengri+"',zuohao='"+zuohao+"',shenfenzheng='"+shenfenzheng+"',minzu='"+minzu+"',jiguan='"+jiguan+"',hukou='"+hukou+"',address='"+address+"',phone='"+phone+"',email='"+email+"',beizhu='"+beizhu+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/xuesheng.jsp?mark="+mark+"&id="+id;
				request.setAttribute("message", "学号重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**

public class ChengjiServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ChengjiServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		String id = request.getParameter("id");
		String name = request.getParameter("name");
		String nianji = request.getParameter("nianji");
		String banzhuren = request.getParameter("banzhuren");
		String renshu = request.getParameter("renshu");
		String shuoming = request.getParameter("shuoming");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
            else
            {
                String s11 = new String(m_binArray,m_startData,(m_endData - m_startData) + 1);
                m_formRequest.putParameter(s3,s11);
            }
            if((char)m_binArray[m_currentIndex + 1] == '-')
            {
                break;
            }
        }
    }

    public int save(String s) throws ServletException,IOException,SmartUploadException
    {
        return save(s,0);
    }

    public int save(String s,int i) throws ServletException,IOException,SmartUploadException
    {
        int j = 0;
        if(s == null)
        {
            s = m_application.getRealPath("/");
            //System.out.println("s == null,m_application.getRealPath:" + s);
        }
        if(s.indexOf("/") != -1)
        {
            if(s.charAt(s.length() - 1) != '/')
            {
                s = s + "/";
                //System.out.println("m_application.getRealPath::" + s);
            }
        }
        else
        {
            if(s.charAt(s.length() - 1) != '\\')
            {
                s = s + "\\";
                //System.out.println("m_application.getRealPath" + s);
            }
        }
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null && mark.equals("add")){
			str = "/admin/kechengtable_list.jsp?kechengid="+kechengid;
			sql = "insert into kechengtable(kecheng,didian,xingqi,shangxiawu,kejie,beizhu) values('"+kechengid+"','"+didian+"','"+xingqi+"','"+shangxiawu+"','"+kejie+"','"+beizhu+"')";
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		if(mark != null && mark.equals("update")){
			str = "/admin/kechengtable_list.jsp?kechengid="+kechengid;
			sql = "update kechengtable set didian='"+didian+"',xingqi='"+xingqi+"',shangxiawu='"+shangxiawu+"',kejie='"+kejie+"',beizhu='"+beizhu+"' where id="+id;
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		
		RequestDispatcher rd=request.getRequestDispatcher(str);
        rd.forward(request,response);
	}

	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class ModifyAdminServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public ModifyAdminServlet() {
		super();
            if(k > 0 && l > 0)
            {
                s3 = s.substring(k,l);
            }
        }
        return s3;
    }

    private String getFileExt(String s)
    {
        String s1; // = new String();
        int i = 0;
        int j = 0;
        if(s == null)
        {
            return null;
        }
        i = s.lastIndexOf('.') + 1;
        j = s.length();
        s1 = s.substring(i,j);
        if(s.lastIndexOf('.') > 0)
        {
            return s1;
        }
        else
        {
            return "";
        }
    }

    private String getContentType(String s)
    {
        String s1 = ""; // = new String();
        String s2 = ""; // = new String();
        int i = 0;
        //boolean flag = false;
        s1 = "Content-Type:";
        i = s.indexOf(s1) + s1.length();
        if(i != -1)
        {
            int j = s.length();
            s2 = s.substring(i,j);
        }
        return s2;
    }

    private String getTypeMIME(String s)
    {
        }
        catch(Exception exception1)
        {
            throw new SmartUploadException("The Form cannot be saved in the specified file (1030).");
        }
    }

    private boolean isVirtual(String s)
    {
        if(m_application.getRealPath(s) != null)
        {
            java.io.File file = new java.io.File(m_application.getRealPath(s));
            return file.exists();
        }
        else
        {
            return false;
        }
    }
}

public class DelServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public DelServlet() {
		super();
	}

	/**
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String sql = "";
		String str = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		AllBean ab = new AllBean();
		
		String adminid = request.getParameter("adminid");
		String laoshi = request.getParameter("laoshi");
		String xuesheng = request.getParameter("xuesheng");
		String banji = request.getParameter("banji");
		String kecheng = request.getParameter("kecheng");
		String chengji = request.getParameter("chengji");
		String kechengtable = request.getParameter("kechengtable");
		String kechengid = request.getParameter("kechengid");
		String taoke = request.getParameter("taoke");
		String tuike = request.getParameter("tuike");
		
		if(adminid != null && !adminid.equals("")){
			str = "/admin/adminlist.jsp";
			sql = "delete from admin where id="+adminid;
			if(adminid.equals("1")){
				request.setAttribute("message", "系统管理员不能删除!");
			}else{
				ib.insertANDupdateANDdel(sql);
				request.setAttribute("message", "操作成功!");
			}
		}
		
		if(laoshi != null && !laoshi.equals("")){
			str = "/admin/jiaoshi_list.jsp";
			sql = "delete from jiaoshi where id="+laoshi;
			ib.insertANDupdateANDdel(sql);
			sql = "update banji set banzhuren=0 where banzhuren="+laoshi;
			ib.insertANDupdateANDdel(sql);
			sql = "delete from kechengtable where kecheng=(select id from kecheng where jiaoshi="+laoshi+")";
			ib.insertANDupdateANDdel(sql);
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class XuankeServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public XuankeServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
        int i = 0;
        int j = 0;
        i = s.indexOf(":") + 1;
        j = s.indexOf(";");
        s1 = s.substring(i,j);
        return s1;
    }

    private void getDataSection()
    {
        //boolean flag = false;
        //String s = "";
        //String s = new String();
        int i = m_currentIndex;
        int j = 0;
        int k = m_boundary.length();
        m_startData = m_currentIndex;
        m_endData = 0;
        while(i < m_totalBytes)
        {
            if(m_binArray[i] == (byte)m_boundary.charAt(j))
            {
                if(j == k - 1)
                {
                    m_endData = ((i - k) + 1) - 3;
                    break;
                }
                i++;
                j++;
            }
            else
            {
                i++;
                j = 0;
            }
        }
        m_currentIndex = m_endData + k + 3;
    }

    private String getDataHeader()
    {
        //boolean flag = false;
            return s.substring(i + 1,s.length());
        }
        i = s.lastIndexOf('\\');
        if(i != -1)
        {
            return s.substring(i + 1,s.length());
        }
        else
        {
            return s;
        }
    }

    public void setDeniedFilesList(String s) throws ServletException,IOException,SQLException
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_deniedFilesList.contains(s2))
                    {
                        m_deniedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }

            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_deniedFilesList.addElement(s2);
            }
        }
        else
        {
            m_deniedFilesList = null;
        }
    }

    public void setAllowedFilesList(String s)
    {
        //String s1 = "";
        if(s != null)
	public ModifyAdminServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		request.setCharacterEncoding("UTF-8");
		
		String mark = request.getParameter("mark");
		
		String newpwd = request.getParameter("newpwd");
		String name = request.getParameter("name");
		String pwd = request.getParameter("pwd");
		
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		String sql = "";
		String str = "";

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值