基于javaweb+mysql的jsp+servlet毕业生离校管理系统(java+jsp+servlet+jquery+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的JSP+Servlet毕业生离校管理系统(java+jsp+servlet+jquery+mysql)
需求分析
使用JSP+Servlet+Mysql技术设计一个毕业生离校管理系统, 整个系统采用BS架构, 为高校方便进行毕业生离校流程进行统一的离校流程, 极大的减少了大量学生同时离校的过程中杂乱的情况, 整个系统分为学生, 教务处, 辅导员, 图书馆, 宿管, 财务处, 系办公室, 管理员登等角色, 不同的角色拥有不同的功能
实现功能
该项目是一个基于JSP+Servlet+Mysql实现的毕业生离校管理系统, 用于统一离校流程, 提升学校管理效率,主要分为如下模块 系统的登录注册模块, 注意只能注册学生账号 学生角色: 可以查看未归还图书信息, 未归还宿舍信息, 欠费信息, 手动发起离线申请 教务处角色: 可以添加离校信息 并确认某人离校 辅导员角色: 辅导员可以登录系统查看离校本人并进行确认离校。 图书馆人员角色: 登录系统添加未归还的图书信息。 宿管处角色: 添加未归还钥匙信息并确认离校状态 财务处角色: 添加欠费信息并确认离校状态
运行环境
jdk1.8,tomcat8.5,mysql5.7,Eclispse/IDEA/MyEclipse
项目技术
jsp, servlet, jquery
技术原理
项目是一个基于JSP+Mysql实现的毕业生离校管理系统, 采用比较传统的javaweb模式进行开发, 除了使用dwr并没有使用任何其他大型框架, 但是本项目的servlet+jsp也是构造了一个符合mvc设计模式及的封装代码, 另外此项目自带一篇毕业论文, 项目可以直接用于毕业设计中
注意事项
系统采用jsp+servlet+mysql编写, eclipse导入项目的时候properties的编码需要调整为utf8 mysql的编码utf8, 需要在dbinfo.properties中修改数据连接与密码
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中dbinfo.properties配置文件中的数据库配置改为自己的配置 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入localhost:8080/xxx 登录
测试账号:
管理员账号:a 密码:a 教务处账号:jwc 密码:0 辅导员账号:fdy 密码:0 图书馆账号:tsg 密码:0 宿管处账号:sgc 密码:0 财务处账号:cwc 密码:0 系办公室账号:xbgs 密码:0
{
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
TXuesheng xuesheng=(TXuesheng)session.getAttribute("user");
String sql="update t_xuesheng set loginpw=? where id=?";
Object[] params={userPwNew,xuesheng.getId()};
DB mydb=new DB();
mydb.doPstm(sql, params);
return "yes";
}
}
public class xbgs_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("xbgstj"))
{
xbgstj(req, res);
}
if(type.endsWith("lxztList"))
{
lxztList(req, res);
public class xbgs_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("xbgstj"))
{
xbgstj(req, res);
}
if(type.endsWith("lxztList"))
{
lxztList(req, res);
}
}
public void xbgstj(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
TUser user = (TUser)req.getSession().getAttribute("user");
String sql="select * from t_queren where user_id="+user.getId();
GetListService gl = new GetListService();
req.setAttribute("querenList", gl.getQuerenList(sql));
req.getRequestDispatcher("admin/tsg/tsgtj.jsp").forward(req, res);
}
fdytj(req, res);
}
}
public void fdytj(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
TUser user = (TUser)req.getSession().getAttribute("user");
String sql="select * from t_queren where user_id="+user.getId();
GetListService gl = new GetListService();
req.setAttribute("querenList", gl.getQuerenList(sql));
req.getRequestDispatcher("admin/fdy/fdytj.jsp").forward(req, res);
}
public void lxqr(HttpServletRequest req,HttpServletResponse res)
{
TUser user = (TUser)req.getSession().getAttribute("user");
int userType = (Integer)req.getSession().getAttribute("userType");
String xuesheng_id = req.getParameter("xuesheng_id");
String shijian = DateUtils.formatDate2Str(new Date(), "yyyy-MM-dd");
DB mydb=new DB();
String sql="insert into t_queren (xuesheng_id,user_id,shijian,lx) " +
"values(?,?,?,?)";
Object[] params={xuesheng_id,user.getId(),shijian,userType};
mydb.doPstm(sql, params);
sql = "update t_xuesheng set zt_fdy=1 where id=?";
Object[] params1={xuesheng_id};
mydb.doPstm(sql, params1);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "cwc?type=cwctj");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void xueshengList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng where zt_fdy=0";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/fdy/xueshengList.jsp").forward(req, res);
{
TXuesheng logXs = (TXuesheng)req.getSession().getAttribute("user");
int xuesheng_id = logXs.getId();
String sql = "select * from t_xuesheng where id="+xuesheng_id;
GetListService gl = new GetListService();
TXuesheng xuesheng = (TXuesheng)gl.getXueshengList(sql).get(0);
Map jwc = new HashMap();
int zt_jwc = xuesheng.getZt_jwc();
jwc.put("zt", zt_jwc);
jwc.put("ztmc", zt_jwc==0?"等待确认":"确认离校");
if(zt_jwc==1)
jwc.put("queren", getQueren(xuesheng_id, 1));
Map fdy = new HashMap();
int zt_fdy = xuesheng.getZt_fdy();
fdy.put("zt", zt_fdy);
fdy.put("ztmc", zt_fdy==0?"等待确认":"确认离校");
if(zt_fdy==1)
fdy.put("queren", getQueren(xuesheng_id, 2));
Map tsg = new HashMap();
int zt_tsg = xuesheng.getZt_tsg();
tsg.put("zt", zt_tsg);
tsg.put("ztmc", zt_tsg==0?"等待确认":"确认离校");
if(zt_tsg==1)
tsg.put("queren", getQueren(xuesheng_id, 3));
Map sgc = new HashMap();
int zt_sgc = xuesheng.getZt_sgc();
sgc.put("zt", zt_sgc);
sgc.put("ztmc", zt_sgc==0?"等待确认":"确认离校");
if(zt_sgc==1)
sgc.put("queren", getQueren(xuesheng_id, 4));
Map cwc = new HashMap();
int zt_cwc = xuesheng.getZt_cwc();
cwc.put("zt", zt_cwc);
cwc.put("ztmc", zt_cwc==0?"等待确认":"确认离校");
if(zt_cwc==1)
cwc.put("queren", getQueren(xuesheng_id, 5));
req.setAttribute("jwc", jwc);
req.setAttribute("fdy", fdy);
req.setAttribute("tsg", tsg);
public class fdy_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxztList"))
{
lxztList(req, res);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("fdytj"))
{
fdytj(req, res);
}
}
public void fdytj(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
TUser user = (TUser)req.getSession().getAttribute("user");
String sql="select * from t_queren where user_id="+user.getId();
GetListService gl = new GetListService();
req.setAttribute("querenList", gl.getQuerenList(sql));
req.getRequestDispatcher("admin/fdy/fdytj.jsp").forward(req, res);
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
public class tsg_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
}
public void xueshengList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng where zt_xuesheng=1";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xbgs/xueshengList.jsp").forward(req, res);
}
public void lxztList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xbgs/lxztList.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
public void sushe_sgc(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select ta.*,tb.xuehao,tb.xingming from t_sushe ta,t_xuesheng tb where ta.xuesheng_id=tb.id";
req.setAttribute("susheList", getSusheList(sql));
req.getRequestDispatcher("admin/sgc/susheList.jsp").forward(req, res);
}
public void sushe_xuesheng(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
TXuesheng logXs = (TXuesheng)req.getSession().getAttribute("user");
int xuesheng_id = logXs.getId();
String sql="select ta.*,tb.xuehao,tb.xingming from t_sushe ta,t_xuesheng tb " +
"where ta.xuesheng_id=tb.id and tb.id="+xuesheng_id;
req.setAttribute("susheList", getSusheList(sql));
req.getRequestDispatcher("admin/sgc/susheList.jsp").forward(req, res);
}
private List getSusheList(String sql)
{
List susheList = new ArrayList();
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TSushe sushe=new TSushe();
sushe.setId(rs.getInt("id"));
sushe.setSushe(rs.getString("sushe"));
sushe.setShuliang(rs.getString("shuliang"));
sushe.setXuehao(rs.getString("xuehao"));
sushe.setXsxm(rs.getString("xingming"));
susheList.add(sushe);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return susheList;
}
{
String sql="select * from t_xuesheng where zt_xuesheng=1";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xbgs/xueshengList.jsp").forward(req, res);
}
public void lxztList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xbgs/lxztList.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
String sql="update t_xuesheng set loginpw=? where id=?";
Object[] params={userPwNew,xuesheng.getId()};
DB mydb=new DB();
mydb.doPstm(sql, params);
return "yes";
}
}
public class xbgs_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("xbgstj"))
{
xbgstj(req, res);
}
if(type.endsWith("lxztList"))
{
lxztList(req, res);
}
private TQueren getQueren(int xuesheng_id,int type)
{
GetListService gl = new GetListService();
String sql = "select * from t_queren where xuesheng_id="+xuesheng_id+" and lx ="+type;
TQueren queren = (TQueren)gl.getQuerenList(sql).get(0);
return queren;
}
public void xuesnenList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xueSheng/xueshengList.jsp").forward(req, res);
}
public void xueshengSele(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng where zt_xuesheng=0";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/xuesheng/xueshengSele.jsp").forward(req, res);
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
public class sgc_servlet extends HttpServlet
{
public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
{
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxqr"))
{
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
else
{
result="yes";
TUser user=new TUser();
user.setId(rs.getInt("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
user.setXingming(rs.getString("xingming"));
user.setXingbie(rs.getString("xingbie"));
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", userType);
session.setAttribute("user", user);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
return result;
}
public String adminPwEdit(String userPwNew)
{
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
TAdmin admin=(TAdmin)session.getAttribute("admin");
String sql="update t_admin set userPw=? where userId=?";
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void sushe_sgc(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select ta.*,tb.xuehao,tb.xingming from t_sushe ta,t_xuesheng tb where ta.xuesheng_id=tb.id";
req.setAttribute("susheList", getSusheList(sql));
req.getRequestDispatcher("admin/sgc/susheList.jsp").forward(req, res);
}
public void sushe_xuesheng(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
TXuesheng logXs = (TXuesheng)req.getSession().getAttribute("user");
int xuesheng_id = logXs.getId();
String sql="select ta.*,tb.xuehao,tb.xingming from t_sushe ta,t_xuesheng tb " +
"where ta.xuesheng_id=tb.id and tb.id="+xuesheng_id;
req.setAttribute("susheList", getSusheList(sql));
req.getRequestDispatcher("admin/sgc/susheList.jsp").forward(req, res);
}
private List getSusheList(String sql)
{
List susheList = new ArrayList();
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TSushe sushe=new TSushe();
sushe.setId(rs.getInt("id"));
sushe.setSushe(rs.getString("sushe"));
sushe.setShuliang(rs.getString("shuliang"));
sushe.setXuehao(rs.getString("xuehao"));
sushe.setXsxm(rs.getString("xingming"));
susheList.add(sushe);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
sushe.setXuehao(rs.getString("xuehao"));
sushe.setXsxm(rs.getString("xingming"));
susheList.add(sushe);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return susheList;
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void destroy()
{
}
}
private List getSusheList(String sql)
{
List susheList = new ArrayList();
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TSushe sushe=new TSushe();
sushe.setId(rs.getInt("id"));
sushe.setSushe(rs.getString("sushe"));
sushe.setShuliang(rs.getString("shuliang"));
sushe.setXuehao(rs.getString("xuehao"));
sushe.setXsxm(rs.getString("xingming"));
susheList.add(sushe);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return susheList;
}
public void dispatch(String targetURI,HttpServletRequest request,HttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request, response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
TXuesheng xuesheng = (TXuesheng)gl.getXueshengList(sql).get(0);
Map jwc = new HashMap();
int zt_jwc = xuesheng.getZt_jwc();
jwc.put("zt", zt_jwc);
jwc.put("ztmc", zt_jwc==0?"等待确认":"确认离校");
if(zt_jwc==1)
jwc.put("queren", getQueren(xuesheng_id, 1));
Map fdy = new HashMap();
int zt_fdy = xuesheng.getZt_fdy();
fdy.put("zt", zt_fdy);
fdy.put("ztmc", zt_fdy==0?"等待确认":"确认离校");
if(zt_fdy==1)
fdy.put("queren", getQueren(xuesheng_id, 2));
Map tsg = new HashMap();
int zt_tsg = xuesheng.getZt_tsg();
tsg.put("zt", zt_tsg);
tsg.put("ztmc", zt_tsg==0?"等待确认":"确认离校");
if(zt_tsg==1)
tsg.put("queren", getQueren(xuesheng_id, 3));
Map sgc = new HashMap();
int zt_sgc = xuesheng.getZt_sgc();
sgc.put("zt", zt_sgc);
sgc.put("ztmc", zt_sgc==0?"等待确认":"确认离校");
if(zt_sgc==1)
sgc.put("queren", getQueren(xuesheng_id, 4));
Map cwc = new HashMap();
int zt_cwc = xuesheng.getZt_cwc();
cwc.put("zt", zt_cwc);
cwc.put("ztmc", zt_cwc==0?"等待确认":"确认离校");
if(zt_cwc==1)
cwc.put("queren", getQueren(xuesheng_id, 5));
req.setAttribute("jwc", jwc);
req.setAttribute("fdy", fdy);
req.setAttribute("tsg", tsg);
req.setAttribute("sgc", sgc);
req.setAttribute("cwc", cwc);
int zt_xuesheng = xuesheng.getZt_xuesheng();
if(zt_jwc==1&&zt_fdy==1&&zt_tsg==1&&zt_sgc==1&&zt_cwc==1)
{
if(zt_xuesheng==0)
req.setAttribute("sqflag",0);