作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本项目为基于SSH的HR人事管理系统,可以完美运行。
主要分为超级管理员与普通管理员两种角色;
管理员主要功能包括:
系统管理员:管理员管理、修改密码;
部门信息管理:部门信息添加、部门信息查询;
员工信息管理:新员工登记、员工信息查询;
合同信息管理:合同信息添加、合同信息查询;
考勤信息管理:员工请假信息查询审核、考勤信息添加、考勤信息查询;
工资信息管理:工资信息添加、工资信息查询;
应聘信息管理:应聘信息添加、应聘信息查询;
调职信息管理:调职信息添加、调职信息查询;
离职信息管理:离职信息添加、离职信息查询;
复职信息管理:复职信息添加、复职信息查询;
系统管理;
普通管理员无法对管理员账号信息修改,其它功能类似;
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:java jdk 1.7;注:本项目目前仅支持jdk 1.7;
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. 后端:Spring Struts2 Hibernate
2. 前端:JSP+css+javascript+jQuery+easyUI+ztree
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,在浏览器中输入http://localhost:8080/login.jsp 登录
运行截图
相关代码
控制器
public class MainCtrl extends HttpServlet {
public MainCtrl() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void go(String url,HttpServletRequest request, HttpServletResponse response)
{
try {
request.getRequestDispatcher(url).forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public void gor(String url,HttpServletRequest request, HttpServletResponse response)
{
try {
response.sendRedirect(url);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String ac = request.getParameter("ac");
if(ac==null)ac="";
CommDAO dao = new CommDAO();
String date = Info.getDateStr();
String today = date.substring(0,10);
String tomonth = date.substring(0,7);
if(ac.equals("login"))
{
String username = request.getParameter("username");
String password = request.getParameter("pwd1");
String utype = request.getParameter("cx");
String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom");
String random = (String)request.getSession().getAttribute("random");
if(!pagerandom.equals(random)&&request.getParameter("a")!=null)
{
request.setAttribute("random", "");
go("/index.jsp", request, response);
}
else{
String sql1="";
if (utype.equals("ע���û�"))
{
sql1 = "select * from yonghuzhuce where yonghuming='"+username+"' and mima='"+password+"' and issh='��'";
}
else
{
sql1 = "select * from yuangongxinxi where gonghao='"+username+"' and mima='"+password+"'";
}
List<HashMap> userlist1 = dao.select(sql1);
if(userlist1.size()==1)
{
if (utype.equals("ע���û�"))
{
request.getSession(). setAttribute("username", userlist1.get(0).get("yonghuming"));
}
else
{
request.getSession(). setAttribute("username", userlist1.get(0).get("gonghao"));
}
request.getSession(). setAttribute("cx", utype);
gor("index.jsp", request, response);
}else{
request.setAttribute("error", "");
go("/index.jsp", request, response);
}
}
}
if(ac.equals("adminlogin"))
{
String username = request.getParameter("username");
String password = request.getParameter("pwd");
String utype = request.getParameter("cx");
String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom");
String random = (String)request.getSession().getAttribute("random");
if(!pagerandom.equals(random)&&request.getParameter("a")!=null)
{
request.setAttribute("random", "");
go("/login.jsp", request, response);
}
else{
String sql1="";
if (utype.equals("Ա��"))
{
sql1 = "select * from yuangongxinxi where yuangongbianhao='"+username+"' and mima='"+password+"'";
}
else
{
if (utype.equals("���ž���"))
{
sql1 = "select * from bumenjingli where bumenbianhao='"+username+"' and mima='"+password+"'";
}
else
{
sql1 = "select * from allusers where username='"+username+"' and pwd='"+password+"'";
}
}
List<HashMap> userlist1 = dao.select(sql1);
if(userlist1.size()==1)
{
if (utype.equals("Ա��"))
{
request.getSession(). setAttribute("username", userlist1.get(0).get("yuangongbianhao"));
request.getSession(). setAttribute("cx", utype);
}
else
{ if (utype.equals("���ž���"))
{
request.getSession(). setAttribute("username", userlist1.get(0).get("bumenbianhao"));
request.getSession(). setAttribute("cx", utype);
}
else
{
request.getSession(). setAttribute("username", userlist1.get(0).get("username"));
request.getSession(). setAttribute("cx", userlist1.get(0).get("cx"));
}
}
gor("main.jsp", request, response);
}else{
request.setAttribute("error", "");
go("/login.jsp", request, response);
}
}
}
if(ac.equals("uppass"))
{
String olduserpass = request.getParameter("ymm");
String userpass = request.getParameter("xmm1");
String copyuserpass = request.getParameter("xmm2");
HashMap m = dao.getmaps("yonghuming",(String)request.getSession().getAttribute("username"), "yonghuzhuce");
if(!(((String)m.get("mima")).equals(olduserpass)))
{
request.setAttribute("error", "");
go("mod2.jsp", request, response);
}else{
//String id = (String)user.get("id");
String sql = "update yonghuzhuce set mima='"+userpass+"' where yonghuming='"+(String)request.getSession().getAttribute("username")+"'";
dao.commOper(sql);
request.setAttribute("suc", "");
go("mod2.jsp", request, response);
}
}
上传控制器
public class Upload extends HttpServlet {
/**
* Constructor of the object.
*/
public Upload() {
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 {
this.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 {
StringBuffer sb = new StringBuffer(50);
response.setContentType("application/x-msdownload;charset=GB2312");
try {
response.setHeader("Content-Disposition", new String(sb.toString()
.getBytes(), "ISO8859-1"));
} catch (UnsupportedEncodingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String filename = request.getParameter("filename");
if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0){
try {
filename = new String(filename.getBytes("gb2312"), "ISO8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0){
try {
filename = URLEncoder.encode(filename, "gb2312");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
}
}
response.setContentType("text/plain");
response.setHeader("Location",filename);
response.reset();
response.setHeader("Cache-Control", "max-age=0" );
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
try {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
OutputStream fos = null;
// File f = new File(request.getRealPath("/upfile/")+"/"+filename);
//System.out.println(f);
bis = new BufferedInputStream((InputStream)new FileInputStream(request.getRealPath("/upfile/")+"/"+filename));
fos = response.getOutputStream();
bos = new BufferedOutputStream(fos);
int bytesRead = 0;
byte[] buffer = new byte[5 * 1024];
while ((bytesRead = bis.read(buffer)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
bis.close();
fos.close();
new Info().delPic(request.getRealPath("/upfile/")+"/", filename);
} catch (Exception e) {
}finally{
}
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
如果也想学习本系统,下面领取。回复:127ssh