基于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项目

技术栈

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

使用说明

使用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,前端代码中已写死,否则会报错;

//boolean flag = false;

int k = 0;

byte abyte0[] = new byte[i];

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((int)l);

m_contentDisposition = m_contentDisposition != null ? m_contentDisposition : "attachment;";

if(s2 == null)

{

m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + getFileName(s));

}

else

{

if(s2.length() == 0)

{

m_response.setHeader("Content-Disposition",m_contentDisposition);

}

else

{

m_response.setHeader("Content-Disposition",m_contentDisposition + " filename=" + s2);

}

}

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).");

*

* 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 id = request.getParameter("id");

HttpSession session = request.getSession();

ArrayList adminlogin = (ArrayList)session.getAttribute("adminlogin");

InsertUpdateDelBean ib = new InsertUpdateDelBean();

String sql = "insert into xuanke(xuesheng,kecheng) values("+adminlogin.get(0)+","+id+")";

ib.insertANDupdateANDdel(sql);

request.setAttribute("message", "操作成功!");

request.getRequestDispatcher("/xuesheng/kecheng_list.jsp").forward(request, response);

}

/**

* Initialization of the servlet.

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}

}

String s10 = ""; //new String();

m_totalBytes = m_request.getContentLength();

m_binArray = new byte[m_totalBytes];

int j;

for(;i < m_totalBytes;i += j)

{

try

{

m_request.getInputStream();

j = m_request.getInputStream().read(m_binArray,i,m_totalBytes - i);

}

catch(Exception exception)

{

throw new SmartUploadException("Unable to upload.");

}

}

for(;!flag1 && m_currentIndex < m_totalBytes;m_currentIndex++)

{

if(m_binArray[m_currentIndex] == 13)

{

flag1 = true;

}

else

{

m_boundary = m_boundary + (char)m_binArray[m_currentIndex];

}

}

if(m_currentIndex == 1)

{

return;

}

for(m_currentIndex++;m_currentIndex < m_totalBytes;m_currentIndex = m_currentIndex + 2)

{

//long now=new java.util.Date().getTime();

String s1 = getDataHeader();

m_currentIndex = m_currentIndex + 2;

boolean flag3 = s1.indexOf("filename") > 0;

String s3 = getDataFieldValue(s1,"name");

if(flag3)

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 && 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 && 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+"&id="+id;

request.setAttribute("message", "课程名称重复!");

}else{

request.setAttribute("message", "操作成功!");

}

}

RequestDispatcher rd=request.getRequestDispatcher(str);

rd.forward(request,response);

}

/**

* Initialization of the servlet.

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

sql = "delete from chengji where id="+chengji;

ib.insertANDupdateANDdel(sql);

request.setAttribute("message", "操作成功!");

}

if(taoke != null && !taoke.equals("")){

str = "/jiaoshi/taoke_list.jsp";

sql = "delete from taoke where id="+taoke;

ib.insertANDupdateANDdel(sql);

request.setAttribute("message", "操作成功!");

}

if(tuike != null && !tuike.equals("")){

str = "/xuesheng/kecheng_list.jsp";

sql = "delete from xuanke where id="+tuike;

ib.insertANDupdateANDdel(sql);

request.setAttribute("message", "操作成功!");

}

RequestDispatcher rd = request.getRequestDispatcher(str);

rd.forward(request,response);

}

/**

* Initialization of the servlet.

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}

}

public void init() throws ServletException {

// Put your code here

}

}

public class BanjiServlet extends HttpServlet {

/**

* Constructor of the object.

*/

public BanjiServlet() {

super();

}

/**

* Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}

/**

* The doGet method of the servlet.

*

* 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

{

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;

}

}

}

str = "/index.jsp";

request.setAttribute("message", "用户名或密码错误!");

}else{

str = "/"+shenfen+"/modifypwd.jsp";

HttpSession session = request.getSession();

session.setAttribute("adminlogin", al);

session.setAttribute("shenfen", shenfen);

}

request.getRequestDispatcher(str).forward(request, response);

}

/**

* Initialization of the servlet.

*

* @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();

}

public class XueshengServlet extends HttpServlet {

/**

* Constructor of the object.

*/

public XueshengServlet() {

super();

}

/**

* Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}

/**

* The doGet method of the servlet.

*

* 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.

*

* 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

*/

* Initialization of the servlet.

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}

}

public class RemoveServlet extends HttpServlet {

/**

* Constructor of the object.

*/

public RemoveServlet() {

super();

}

/**

* Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}

/**

* The doGet method of the servlet.

*

* This method is called when a form has its tag value method equals to get.

}

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) && 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);

}

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)

{

*/

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

doPost(request, response);

}

/**

* The doPost method of the servlet.

*

* 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 = "";

String sql = "";

InsertUpdateDelBean ib = new InsertUpdateDelBean();

if(mark != null && mark.equals("add")){

str = "/admin/jiaoshi_list.jsp";

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

{

int i = 0;

//boolean flag = false;

boolean flag1 = false;

//boolean flag2 = false;

long l = 0L;

//String s = "";//new String();

//String s2 = "";//new String();

String s4 = ""; //new String();

String s5 = ""; //new String();

String s6 = ""; //new String();

String s7 = ""; //new String();

String s8 = ""; //new String();

String s9 = ""; //new String();

String s10 = ""; //new String();

m_totalBytes = m_request.getContentLength();

m_binArray = new byte[m_totalBytes];

public class KechengtableServlet extends HttpServlet {

/**

* Constructor of the object.

*/

public KechengtableServlet() {

super();

}

/**

* Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}

/**

* The doGet method of the servlet.

*

* 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.

*

* 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

request.setAttribute("message", "操作成功!");

}

RequestDispatcher rd = request.getRequestDispatcher(str);

rd.forward(request,response);

}

/**

* Initialization of the servlet.

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}

}

public class XueshengServlet extends HttpServlet {

/**

* Constructor of the object.

*/

public XueshengServlet() {

super();

}

/**

* Destruction of the servlet.

*/

public void destroy() {

super.destroy(); // Just puts "destroy" string in log

// Put your code here

}

/**

* The doGet method of the servlet.

*

* This method is called when a form has its tag value method equals to get.

{

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)

{

String s2 = "";

for(int i = 0;i < s.length();i++)

{

if(s.charAt(i) == ',')

{

if(!m_allowedFilesList.contains(s2))

{

m_allowedFilesList.addElement(s2);

m_endData = 0;

m_boundary = ""; //new String();

m_totalMaxFileSize = 0L;

m_maxFileSize = 0L;

m_deniedFilesList = new Vector();

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;

}

//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;

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++;

}

好文阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: