基于JSP实现人力资源管理系统

Posted 编程指南针

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于JSP实现人力资源管理系统相关的知识,希望对你有一定的参考价值。

项目编号:BS-XX-096

运行环境

MyEclipse(idea) + Tomcat7,8 + mysql5.5+jdk7,8

项目技术(必填)

Jsp+Servlet+apache dbutils+jdbc+c3p0+bootstrap+jquery

项目说明:

本系统主要实现对企业的人力资源信息的管理功能,主要包含的模块儿有:

  招聘管理、职位管理、部门管理、培训管理、薪金管理、用户管理、下载中心、系统管理几个模块。

下面展示一下主要的系统功能

后台主界面

招聘管理

职位管理

部门管理

培训管理

薪酬管理

用户管理

下载中心

系统管理

部门核心实现代码:

package com.hr.service.impl;
import java.util.List;

import com.hr.dao.AdminDao;
import com.hr.dao.impl.AdminDaoImpl;
import com.hr.pojo.Admin;
import com.hr.service.AdminService;
public class AdminServiceImpl implements AdminService 
	private	AdminDao userDao = new AdminDaoImpl();
	@Override
	public Admin findUserByUsernameAndPassword(String username, String password) 
		Admin user = userDao.findUserByUsernameAndPassword(username,  password);
		return user;
	
	@Override
	public void saveUser(Admin user) 
		AdminDao userDao = new AdminDaoImpl();
		userDao.saveUser(user);
	
	@Override
	public List findAllUsers() 
		AdminDao userDao = new AdminDaoImpl();
		return userDao.findAllUsers();
	
	@Override
	public Admin findUserById(String id) 
		AdminDao userDao = new AdminDaoImpl();
		Admin user=userDao.findUserById(id);
		return user;
	
	@Override
	public void updateUser(Admin user) 
		AdminDao userDao = new AdminDaoImpl();
		userDao.updateUser(user);
	
	@Override
	public void delete(String id) 
		AdminDao userDao = new AdminDaoImpl();
		userDao.delete(id);
	

package com.hr.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hr.pojo.Admin;
import com.hr.service.AdminService;
import com.hr.service.ApplicantService;
import com.hr.service.impl.AdminServiceImpl;
import com.hr.service.impl.ApplicantServiceImpl;
import com.hr.utils.DateUtil;
import com.hr.utils.StringUtil;
public class AdminServlet extends BaseServlet 
	private AdminService adminService=new AdminServiceImpl();
	private ApplicantService applicantService=new ApplicantServiceImpl();
	//管理员登录
	public String adminLogin(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException 
		//接受用户名和用户密码
		String username=request.getParameter("username");
		String password=request.getParameter("password");

		//MD5加密密码
		password=StringUtil.stringToMD5(password);
		
		//调用业务层功能 : 根据用户名查找用户  select * from user where username=?, 返回用户
		Admin admin=adminService.findUserByUsernameAndPassword(username,password);
		//根据返回的用户是否为空,判断用户是否已经存在  ,向客户端响应		
		if(null!=admin)
			
			response.setContentType("text/html;charset=utf-8");   
			request.getRequestDispatcher("/public/alert.jsp").include(request, response);
			PrintWriter out = response.getWriter();
			if(admin.getPassword().equals(password)) 
				request.getSession().setAttribute("admin",admin);
				out.println("<script>ok_alert(\\"登录成功\\",\\"main.jsp\\");</script>");
			else 
				out.println("<script>no_alert(\\"登录失败,密码错误!\\",\\"index.jsp\\");</script>");
			
			
		else
			response.setContentType("text/html;charset=utf-8");   
			request.getRequestDispatcher("/index.jsp").include(request, response);  
	        PrintWriter out = response.getWriter();
	        out.println("<script>no_alert(\\"登录失败,找不到该用户!\\",\\"index.jsp\\");</script>");
		
		return null;
	
	//退出
	public String adminLogout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, SQLException 
		request.getSession().removeAttribute("admin");
		response.setContentType("text/html;charset=utf-8");   
		request.getRequestDispatcher("/main.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"退出成功\\",\\"index.jsp\\");</script>");
		return null;
	
	public String toAddPage(HttpServletRequest request, HttpServletResponse response) throws Exception	
		response.setCharacterEncoding("UTF-8");
		request.getRequestDispatcher("/admin/adduser.jsp").include(request, response);
		return null;
		
	
	//管理员添加
	public String adminAdd(HttpServletRequest request, HttpServletResponse response) throws Exception
		Admin admin = new Admin();
		admin.setUsername(request.getParameter("username"));
		admin.setPassword(StringUtil.stringToMD5(request.getParameter("password")));//加密
		admin.setSex(new Byte(request.getParameter("sex")));
		admin.setBirthday(DateUtil.parseToDate(request.getParameter("birthday"), DateUtil.yyyyMMdd));
		admin.setCreatetime(new java.util.Date());
		admin.setContent(request.getParameter("content"));
		String applicantId=request.getParameter("applicantId");
		admin.setIfadmin(new Byte("0"));
		if(applicantId!="") admin.setIfadmin(new Byte("1"));
		adminService.saveUser(admin);
		if(applicantId!="") 
			admin.setIfadmin(new Byte("1"));
			List adminList=adminService.findAllUsers();
			Admin u=(Admin)adminList.get(adminList.size() - 1);
			applicantService.updateadminApplicant(applicantId,u.getId().toString());
		;
		response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        //跳转到列表页面
        if(applicantId!="") 
        	out.println("<script>ok_alert(\\"员工录用成功!\\",\\"main.jsp?method=findApplicantByIsstock&isstock=3&servlet=ApplicantServlet\\");</script>");
        else 
        	out.println("<script>ok_alert(\\"添加成功!\\",\\"main.jsp?method=adminList&servlet=AdminServlet\\");</script>");
        
		return null;
	
	//管理员list
	public List adminList(HttpServletRequest request, HttpServletResponse response) throws Exception
		response.setContentType("text/html;charset=utf-8");
		List adminList=adminService.findAllUsers();
		request.setAttribute("adminList", adminList);
		request.getRequestDispatcher("/admin/listadmin.jsp").include(request, response);
		return null;
	
	//更新管理员页面
	public String toUpdatePage(HttpServletRequest request, HttpServletResponse response) throws Exception	
		String  id = request.getParameter("id");		
		Admin adminuser =adminService.findUserById(id);
		request.setAttribute("admin", adminuser);
		response.setContentType("text/html;charset=utf-8");
		request.getRequestDispatcher("/admin/updateuser.jsp").include(request, response);
		return null;
	
	//更新管理员
	public String updateAdmin(HttpServletRequest request, HttpServletResponse response) throws Exception
		Admin user = new Admin();
		user.setId(new Long(request.getParameter("id")));
		user.setUsername(request.getParameter("username"));
		user.setPassword(request.getParameter("password"));
		user.setSex(new Byte(request.getParameter("sex")));
		user.setBirthday(DateUtil.parseToDate(request.getParameter("birthday"), DateUtil.yyyyMMdd));
		//user.setCreatetime(new java.util.Date());
		user.setContent(request.getParameter("content"));		
		
		adminService.updateUser(user);
		List adminList=adminService.findAllUsers();
		request.setAttribute("adminList", adminList);

		response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"修改成功\\",\\"main.jsp?method=adminList&servlet=AdminServlet\\");</script>");
		return null;
	
	//删除管理员
	public String deleteAdmin(HttpServletRequest request, HttpServletResponse response) throws Exception
		String id = request.getParameter("id");
		
		adminService.delete(id);
		response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"删除成功\\",\\"main.jsp?method=adminList&servlet=AdminServlet\\");</script>");
		return null;
	

package com.hr.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hr.pojo.Department;
import com.hr.pojo.Position;
import com.hr.service.DepartmentService;
import com.hr.service.impl.DepartmentServiceImpl;


public class DepartmentServlet  extends BaseServlet 
	private DepartmentService departmentService=new DepartmentServiceImpl();
	
    public String listDepartment(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
		response.setContentType("text/html;charset=utf-8");  
		List departmentList= departmentService.findAllDepartments();
		request.setAttribute("departmentList", departmentList);
		request.getRequestDispatcher("/admin/listdepartment.jsp").include(request, response);
    	return null; 
    
    public String addDepartment(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
		response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("/admin/adddepartment.jsp").include(request, response);
    	return null; 
    
    public String toUpdatePage(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
    	Department department =new Department();
    	department.setName(request.getParameter("name"));
    	department.setId(new Long(request.getParameter("id")));
    	departmentService.updateDepartment(department);
    	response.setContentType("text/html;charset=utf-8");  
    	request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"修改成功!\\",\\"main.jsp?method=listDepartment&servlet=DepartmentServlet\\");</script>");
    	return null;
    
    public String UpdateDepartment(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
		String  id = request.getParameter("id");	
    	response.setContentType("text/html;charset=utf-8");  
    	Department departmentList= departmentService.findDepartmentById(id);
		request.setAttribute("departmentList", departmentList);
    	response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("/admin/updatedepartment.jsp").include(request, response);
    	return null; 
    
    
    public String addToDepartment(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
    	Department department =new Department();
    	department.setName(request.getParameter("name"));
    	departmentService.saveDepartment(department);
    	response.setContentType("text/html;charset=utf-8");  
    	request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"添加成功!\\",\\"main.jsp?method=listDepartment&servlet=DepartmentServlet\\");</script>");
    	return null;    	
    
	public String departmentDelete(HttpServletRequest request, HttpServletResponse response) throws Exception
		String id = request.getParameter("id");
		departmentService.delete(id);
		response.setContentType("text/html;charset=utf-8");  
		request.getRequestDispatcher("./public/alert.jsp").include(request, response);
        PrintWriter out = response.getWriter();
        out.println("<script>ok_alert(\\"删除成功\\",\\"main.jsp?method=listDepartment&servlet=DepartmentServlet\\");</script>");
		return null;
	

以上是关于基于JSP实现人力资源管理系统的主要内容,如果未能解决你的问题,请参考以下文章

⭐基于bootstap-Jquery-JSP-Servlet-mysql⭐博客项目——后台资源管理demo1

⭐基于bootstap-Jquery-JSP-Servlet-mysql⭐博客项目——后台资源管理demo1

⭐基于bootstap-Jquery-JSP-Servlet-mysql⭐博客项目——后台资源管理demo2

⭐基于bootstap-Jquery-JSP-Servlet-mysql⭐博客项目——后台资源管理demo2

基于Javaweb实现人力资源管理系统

基于java jsp asp php vb安卓系统毕业设计与实现论文源码下载?