本文介绍: 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境windows 7/8/10 1G内存以上;管理员角色包含以下功能管理员登录,学生管理,教师管理,班级管理,添加班级,添加教师,添加学生,课程管理,添加课程,系统用户管理,添加用户,修改密码功能。教师角色包含以下功能: 教师登录,选课管理,添加选课学生,成绩管理,添加成绩,查看学生信息,查看班级信息,查看个人档案,修改密码功能学生角色包含以下功能学生登录,选课管理,成绩查看,查看个人档案,修改密码功能

基于javaweb+mysqljsp+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.propertiesspringmybatis.xml配置文件中的数据库配置改为自己配置; 注:在springmybatis.xml没有db.properties数据同步过去的情况下修改; 4. 运行项目,输入localhost:8080/chaoshi 登录 注:tomcat配置项目路径必须为/chaoshi前端代码中已写死,否则会报错
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br&gt;
	 *
	 * 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&gt;
	 *
	 * 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 pwd = request.getParameter("pwd");
		String jiaoshihao = request.getParameter("jiaoshihao");
		String zhenname = request.getParameter("zhenname");
		String sex = request.getParameter("sex");
		String shengri = request.getParameter("shengri");
		String yuanxiao = request.getParameter("yuanxiao");
		String zhuanye = request.getParameter("zhuanye");
		String phone = request.getParameter("phone");
		String address = request.getParameter("address");
		String email = request.getParameter("email");
		
		String str = "";

public class TaokeServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public TaokeServlet() {
		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>
            }
            if(isVirtual(s1))
            {
                throw new IllegalArgumentException("The path is not a physical path.");
            }
            else
            {
                throw new IllegalArgumentException("This path does not exist (1135).");
            }
        }
        else
        {
            return null;
        }
    }

    public void uploadInFile(String s) throws IOException,SmartUploadException
    {
        //boolean flag = false;
        int i = 0;
        int j = 0;
        if(s == null)
        {
            throw new IllegalArgumentException("There is no specified destination file (1025).");
        }
        if(s.length() == 0)
        {
            throw new IllegalArgumentException("There is no specified destination file (1025).");
        }
        if(!isVirtual(s) &amp;&amp; m_denyPhysicalPath)
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        i = m_request.getContentLength();
        m_binArray = new byte[i];
        int k;
        for(;j < i;j += k)
        {
            try
            {
                k = m_request.getInputStream().read(m_binArray,j,i - j);
            }

public class TaokeServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public TaokeServlet() {
		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 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 jiaoshi = request.getParameter("jiaoshi");
		String keshi = request.getParameter("keshi");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null &amp;&amp; mark.equals("add")){
			str = "/admin/kecheng_list.jsp";
			sql = "insert into kecheng(name,jiaoshi,keshi,beizhu) values('"+name+"','"+jiaoshi+"','"+keshi+"','"+beizhu+"')";
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/kecheng.jsp?mark="+mark;
				request.setAttribute("message", "课程名称重复!");
			}else{
				request.setAttribute("message", "操作成功!");
			}
		}
		if(mark != null &amp;&amp; mark.equals("update")){
			str = "/admin/kecheng_list.jsp";
			sql = "update kecheng set name='"+name+"',jiaoshi='"+jiaoshi+"',keshi='"+keshi+"',beizhu='"+beizhu+"' where id="+id;
			int flag = ib.insertANDupdateANDdel(sql);
			if(flag == -1){
				str = "/admin/kecheng.jsp?mark="+mark+"&amp;id="+id;
				request.setAttribute("message", "课程名称重复!");
			}else{
				request.setAttribute("message", "操作成功!");
                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);
            }
        }
        //System.out.println("m_application.getRealPath:::" + s);
        FileNames = new String[m_files.getCount()];
        for(int k = 0;k < m_files.getCount();k++)
        {
            if(!m_files.getFile(k).isMissing())
            {
              //  System.out.println("s + m_files.getFile(k).getFileName():" + s + m_files.getFile(k).getFileName());
                m_files.getFile(k).saveAs(s + m_files.getFile(k).getFileName(),i);
                FileNames[j] = s + m_files.getFile(k).getFileName();
                j++;
            }
        }
        return j;
    }

    //Add

    public void downloadFile(String s) throws ServletException,IOException,SmartUploadException
    {
        downloadFile(s,null,null);
    }

    public void downloadFile(String s,String s1) throws ServletException,IOException,SmartUploadException,SmartUploadException
    {
        downloadFile(s,s1,null);
    }

    public void downloadFile(String s,String s1,String s2) throws ServletException,IOException,SmartUploadException
    {
        downloadFile(s,s1,s2,65000);
    }

    public void downloadFile(String s,String s1,String s2,int i) throws ServletException,IOException,SmartUploadException
    {
        if(s == null)
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(s.equals(""))
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(!isVirtual(s) &amp;&amp; m_denyPhysicalPath)
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        if(isVirtual(s))
        {
            s = m_application.getRealPath(s);
        }
        java.io.File file = new java.io.File(s);
        FileInputStream fileinputstream = new FileInputStream(file);
        long l = file.length();
        //boolean flag = false;
        int k = 0;
        byte abyte0[] = new byte[i];
        if(s1 == null)
        {
            m_response.setContentType("application/x-msdownload");
        }
        else
        {
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}

public class LaoshiServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public LaoshiServlet() {
		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);
	}

		String xingqi = request.getParameter("xingqi");
		String shangxiawu = request.getParameter("shangxiawu");
		String kejie = request.getParameter("kejie");
		String beizhu = request.getParameter("beizhu");
		
		String str = "";
		String sql = "";
		InsertUpdateDelBean ib = new InsertUpdateDelBean();
		
		if(mark != null &amp;&amp; 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 &amp;&amp; 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
	}

}

            byte0 = m_binArray[i];
        }
        catch(Exception exception)
        {
            throw new ArrayIndexOutOfBoundsException("Index out of range (1005).");
        }
        return byte0;
    }

    public SmartFiles getFiles()
    {
        return m_files;
    }

    public SmartRequest getRequest()
    {
        return m_formRequest;
    }

    public void downloadFile(String s) throws ServletException,IOException,SmartUploadException
    {
        downloadFile(s,null,null);
    }

    public void downloadFile(String s,String s1) throws ServletException,IOException,SmartUploadException,SmartUploadException
    {
        downloadFile(s,s1,null);
    }

    public void downloadFile(String s,String s1,String s2) throws ServletException,IOException,SmartUploadException
    {
        downloadFile(s,s1,s2,65000);
    }

    public void downloadFile(String s,String s1,String s2,int i) throws ServletException,IOException,SmartUploadException
    {
        if(s == null)
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(s.equals(""))
        {
            throw new IllegalArgumentException("File '" + s + "' not found (1040).");
        }
        if(!isVirtual(s) &amp;&amp; m_denyPhysicalPath)
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        if(isVirtual(s))
        {
            s = m_application.getRealPath(s);
			sql = "insert into chengji(xuesheng,kemu,shijian,fenshu) values('"+xuesheng+"','"+kemu+"','"+shijian+"','"+fenshu+"')";
			ib.insertANDupdateANDdel(sql);
			request.setAttribute("message", "操作成功!");
		}
		if(mark != null &amp;& mark.equals("update")){
			str = "/jiaoshi/chengji_list.jsp";
			sql = "update chengji set xuesheng='"+xuesheng+"',kemu='"+kemu+"',shijian='"+shijian+"',fenshu='"+fenshu+"' 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 UserLoginServlet extends HttpServlet {

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

	/**
	 * Destruction of the servlet. <br>
        m_allowedFilesList = new Vector();
        m_denyPhysicalPath = false;
        //m_forcePhysicalPath = false;
        m_contentDisposition = ""; //new String();
        m_files = new SmartFiles();
        m_formRequest = new SmartRequest();
    }

    /**
     * @deprecated Method init is deprecated
     */
    public final void init(ServletConfig servletconfig) throws ServletException
    {
        m_application = servletconfig.getServletContext();
    }

    /**
     * @deprecated Method service is deprecated
     */
    public void service(HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException,IOException
    {
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public final void initialize(ServletConfig servletconfig,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse) throws ServletException
    {
        m_application = servletconfig.getServletContext();
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public final void initialize(PageContext pagecontext) throws ServletException
    {
        m_application = pagecontext.getServletContext();
        m_request = (HttpServletRequest)pagecontext.getRequest();
        m_response = (HttpServletResponse)pagecontext.getResponse();
    }

    /**
     * @deprecated Method initialize is deprecated
     */
    public final void initialize(ServletContext servletcontext,HttpSession httpsession,HttpServletRequest httpservletrequest,HttpServletResponse httpservletresponse,JspWriter jspwriter) throws ServletException
    {
        m_application = servletcontext;
        m_request = httpservletrequest;
        m_response = httpservletresponse;
    }

    public void upload() throws ServletException,IOException,SmartUploadException
    {
        {
            throw new SecurityException("Physical path is denied (1035).");
        }
        i = m_request.getContentLength();
        m_binArray = new byte[i];
        int k;
        for(;j < i;j += k)
        {
            try
            {
                k = m_request.getInputStream().read(m_binArray,j,i - j);
            }
            catch(Exception exception)
            {
                throw new SmartUploadException("Unable to upload.");
            }
        }

        if(isVirtual(s))
        {
            s = m_application.getRealPath(s);
        }
        try
        {
            java.io.File file = new java.io.File(s);
            FileOutputStream fileoutputstream = new FileOutputStream(file);
            fileoutputstream.write(m_binArray);
            fileoutputstream.close();
        }
        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;
        }
    }
                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());
        }
        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 = "";
                }
            fileoutputstream.close();
        }
        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();
	}

        }
        else
        {
            m_deniedFilesList = null;
        }
    }

    public void setAllowedFilesList(String s)
    {
        //String s1 = "";
        if(s != null)
        {
            String s2 = "";
            for(int i = 0;i < s.length();i++)
            {
                if(s.charAt(i) == ',')
                {
                    if(!m_allowedFilesList.contains(s2))
                    {
                        m_allowedFilesList.addElement(s2);
                    }
                    s2 = "";
                }
                else
                {
                    s2 = s2 + s.charAt(i);
                }
            }
            //if(s2 != "")
            if(!s2.equals(""))
            {
                m_allowedFilesList.addElement(s2);
            }
        }
        else
        {
            m_allowedFilesList = null;
        }
    }

    public void setDenyPhysicalPath(boolean flag)
    {
        m_denyPhysicalPath = flag;
    }

    public void setForcePhysicalPath(boolean flag)
    {
        //m_forcePhysicalPath = flag;
    }

    public void setContentDisposition(String s)
    {
        if(i != -1)
        {
            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);
            }

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

原文地址:https://blog.csdn.net/2301_81060862/article/details/134606867

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_39158.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注