基于javaweb+mysql的jsp+servlet毕业生离校管理系统(java+jsp+servlet+jquery+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的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
session.setAttribute("admin", admin);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
else if(userType==7)//学生登陆
{
String sql="select * from t_xuesheng where xuehao=? and loginpw=?";
Object[] params={userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
else
{
result="yes";
TXuesheng xuesheng=new TXuesheng();
xuesheng.setId(rs.getInt("id"));
xuesheng.setXuehao(rs.getString("xuehao"));
xuesheng.setLoginpw(rs.getString("loginpw"));
xuesheng.setXingming(rs.getString("xingming"));
xuesheng.setXingbie(rs.getString("xingbie"));
xuesheng.setRuxue(rs.getString("ruxue"));
xuesheng.setShenfenzheng(rs.getString("shenfenzheng"));
TAdmin admin=new TAdmin();
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", 0);
session.setAttribute("admin", admin);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
else if(userType==7)//学生登陆
{
String sql="select * from t_xuesheng where xuehao=? and loginpw=?";
Object[] params={userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
else
{
result="yes";
TXuesheng xuesheng=new TXuesheng();
xuesheng.setId(rs.getInt("id"));
xuesheng.setXuehao(rs.getString("xuehao"));
xuesheng.setLoginpw(rs.getString("loginpw"));
xuesheng.setXingming(rs.getString("xingming"));
xuesheng.setXingbie(rs.getString("xingbie"));
xuesheng.setRuxue(rs.getString("ruxue"));
public class loginService
{
public String login(String userName,String userPw,int userType)
{
String result="no";
System.out.println(userName+"..."+userPw+"...."+userType);
if(userType==0)//系统管理员登陆
{
String sql="select * from t_admin where userName=? and userPw=?";
Object[] params={userName,userPw};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
ResultSet rs=mydb.getRs();
boolean mark=(rs==null||!rs.next()?false:true);
if(mark==false)
{
result="no";
}
else
{
result="yes";
TAdmin admin=new TAdmin();
admin.setUserId(rs.getInt("userId"));
admin.setUserName(rs.getString("userName"));
admin.setUserPw(rs.getString("userPw"));
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", 0);
session.setAttribute("admin", admin);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
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);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("tsgtj"))
{
tsgtj(req, res);
}
if(type.endsWith("jieyueAdd"))
{
jieyueAdd(req, res);
}
if(type.endsWith("jieyue_tsg"))
{
jieyue_tsg(req, res);
}
if(type.endsWith("jieyue_xuesheng"))
{
jieyue_xuesheng(req, res);
}
}
public void xueshengList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng where zt_tsg=0";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
String type=req.getParameter("type");
if(type.endsWith("xueshengList"))
{
xueshengList(req, res);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("tsgtj"))
{
tsgtj(req, res);
}
if(type.endsWith("jieyueAdd"))
{
jieyueAdd(req, res);
}
if(type.endsWith("jieyue_tsg"))
{
jieyue_tsg(req, res);
}
if(type.endsWith("jieyue_xuesheng"))
{
jieyue_xuesheng(req, res);
}
}
public void xueshengList(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
String sql="select * from t_xuesheng where zt_tsg=0";
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/tsg/xueshengList.jsp").forward(req, res);
}
public void tsgtj(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
}
if(type.endsWith("lxsq"))
{
lxsq(req, res);
}
if(type.endsWith("lxsqAdd"))
{
lxsqAdd(req, res);
}
if(type.endsWith("xueshengSele"))
{
xueshengSele(req, res);
}
}
public void lxsqAdd(HttpServletRequest req,HttpServletResponse res)
{
TXuesheng xuesheng = (TXuesheng)req.getSession().getAttribute("user");
String sql = "update t_xuesheng set zt_xuesheng=1 where id=?";
DB mydb=new DB();
Object[] params={xuesheng.getId()};
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "xuesheng?type=lxsq");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void xueshengAdd(HttpServletRequest req,HttpServletResponse res)
{
String fujian = req.getParameter("fujian");
String strRealPath = this.getServletContext().getRealPath("/");
String uploadFile = strRealPath+"/"+fujian;
try{
DB mydb=new DB();
XlsTools tool = new XlsTools();
tool.read(uploadFile);
int rowCount = tool.getRowCount();
String[] ssTemp = null;
for(int i=1;i<rowCount;i++){
ssTemp = tool.readLine(i);
String xuehao = ssTemp[0];
String loginpw = "0";
String xingming = ssTemp[1];
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);
}
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);
}
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_xbgs=1,zt_xuesheng=2 where id=?";
Object[] params1={xuesheng_id};
mydb.doPstm(sql, params1);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "xbgs?type=xbgstj");
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_xuesheng=1";
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);
}
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/fdy/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()
{
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "user?type=userMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void userDel(HttpServletRequest req,HttpServletResponse res)
{
String id=req.getParameter("id");
String sql="update t_user set del='yes' where id=?";
Object[] params={id};
DB mydb=new DB();
mydb.doPstm(sql, params);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "user?type=userMana");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void userMana(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException
{
List userList=new ArrayList();
String sql="select * from t_user where del='no'";
Object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql, params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TUser user=new TUser();
user.setId(rs.getInt("id"));
user.setLoginname(rs.getString("loginname"));
user.setLoginpw(rs.getString("loginpw"));
}
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()
{
}
}
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", 7);
session.setAttribute("user", xuesheng);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
else
{
String sql="select * from t_user where loginname=? and loginpw=? and zhiwu=? and del='no'";
Object[] params={userName,userPw,userType};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
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 (ServletException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
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"))
{
TJieyue jieyue=new TJieyue();
jieyue.setId(rs.getInt("id"));
jieyue.setZhenghao(rs.getString("zhenghao"));
jieyue.setMingcheng(rs.getString("mingcheng"));
jieyue.setShijian(rs.getString("shijian"));
jieyue.setXuehao(rs.getString("xuehao"));
jieyue.setXsxm(rs.getString("xingming"));
jieyueList.add(jieyue);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
return jieyueList;
}
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 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);
}
if(type.endsWith("lxqr"))
{
lxqr(req, res);
}
if(type.endsWith("tsgtj"))
{
tsgtj(req, res);
}
GetListService gl = new GetListService();
req.setAttribute("xueshengList", gl.getXueshengList(sql));
req.getRequestDispatcher("admin/sgc/xueshengList.jsp").forward(req, res);
}
public void sgctj(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/sgc/sgctj.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_sgc=1 where id=?";
Object[] params1={xuesheng_id};
mydb.doPstm(sql, params1);
mydb.closed();
req.setAttribute("message", "操作成功");
req.setAttribute("path", "sgc?type=sgctj");
String targetURL = "/common/success.jsp";
dispatch(targetURL, req, res);
}
public void susheAdd(HttpServletRequest req,HttpServletResponse res)
{
String xuesheng_id = req.getParameter("xuesheng_id");
String sushe = req.getParameter("sushe");
String shuliang = req.getParameter("shuliang");
WebContext ctx = WebContextFactory.get();
HttpSession session=ctx.getSession();
session.setAttribute("userType", 7);
session.setAttribute("user", xuesheng);
}
rs.close();
}
catch (SQLException e)
{
System.out.println("登录失败!");
e.printStackTrace();
}
finally
{
mydb.closed();
}
}
else
{
String sql="select * from t_user where loginname=? and loginpw=? and zhiwu=? and del='no'";
Object[] params={userName,userPw,userType};
DB mydb=new DB();
mydb.doPstm(sql, params);
try
{
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);