• SSH基于SSH的HR人事管理系统


    作者主页:夜未央5788

     简介: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 登录

    运行截图

     

     

     

     

     

     

    相关代码

    控制器

    1. public class MainCtrl extends HttpServlet {
    2. public MainCtrl() {
    3. super();
    4. }
    5. public void destroy() {
    6. super.destroy(); // Just puts "destroy" string in log
    7. // Put your code here
    8. }
    9. public void doGet(HttpServletRequest request, HttpServletResponse response)
    10. throws ServletException, IOException {
    11. this.doPost(request, response);
    12. }
    13. public void go(String url,HttpServletRequest request, HttpServletResponse response)
    14. {
    15. try {
    16. request.getRequestDispatcher(url).forward(request, response);
    17. } catch (ServletException e) {
    18. e.printStackTrace();
    19. } catch (IOException e) {
    20. e.printStackTrace();
    21. }
    22. }
    23. public void gor(String url,HttpServletRequest request, HttpServletResponse response)
    24. {
    25. try {
    26. response.sendRedirect(url);
    27. } catch (IOException e) {
    28. // TODO Auto-generated catch block
    29. e.printStackTrace();
    30. }
    31. }
    32. public void doPost(HttpServletRequest request, HttpServletResponse response)
    33. throws ServletException, IOException {
    34. response.setContentType("text/html");
    35. PrintWriter out = response.getWriter();
    36. String ac = request.getParameter("ac");
    37. if(ac==null)ac="";
    38. CommDAO dao = new CommDAO();
    39. String date = Info.getDateStr();
    40. String today = date.substring(0,10);
    41. String tomonth = date.substring(0,7);
    42. if(ac.equals("login"))
    43. {
    44. String username = request.getParameter("username");
    45. String password = request.getParameter("pwd1");
    46. String utype = request.getParameter("cx");
    47. String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom");
    48. String random = (String)request.getSession().getAttribute("random");
    49. if(!pagerandom.equals(random)&&request.getParameter("a")!=null)
    50. {
    51. request.setAttribute("random", "");
    52. go("/index.jsp", request, response);
    53. }
    54. else{
    55. String sql1="";
    56. if (utype.equals("ע���û�"))
    57. {
    58. sql1 = "select * from yonghuzhuce where yonghuming='"+username+"' and mima='"+password+"' and issh='��'";
    59. }
    60. else
    61. {
    62. sql1 = "select * from yuangongxinxi where gonghao='"+username+"' and mima='"+password+"'";
    63. }
    64. List<HashMap> userlist1 = dao.select(sql1);
    65. if(userlist1.size()==1)
    66. {
    67. if (utype.equals("ע���û�"))
    68. {
    69. request.getSession(). setAttribute("username", userlist1.get(0).get("yonghuming"));
    70. }
    71. else
    72. {
    73. request.getSession(). setAttribute("username", userlist1.get(0).get("gonghao"));
    74. }
    75. request.getSession(). setAttribute("cx", utype);
    76. gor("index.jsp", request, response);
    77. }else{
    78. request.setAttribute("error", "");
    79. go("/index.jsp", request, response);
    80. }
    81. }
    82. }
    83. if(ac.equals("adminlogin"))
    84. {
    85. String username = request.getParameter("username");
    86. String password = request.getParameter("pwd");
    87. String utype = request.getParameter("cx");
    88. String pagerandom = request.getParameter("pagerandom")==null?"":request.getParameter("pagerandom");
    89. String random = (String)request.getSession().getAttribute("random");
    90. if(!pagerandom.equals(random)&&request.getParameter("a")!=null)
    91. {
    92. request.setAttribute("random", "");
    93. go("/login.jsp", request, response);
    94. }
    95. else{
    96. String sql1="";
    97. if (utype.equals("Ա��"))
    98. {
    99. sql1 = "select * from yuangongxinxi where yuangongbianhao='"+username+"' and mima='"+password+"'";
    100. }
    101. else
    102. {
    103. if (utype.equals("���ž���"))
    104. {
    105. sql1 = "select * from bumenjingli where bumenbianhao='"+username+"' and mima='"+password+"'";
    106. }
    107. else
    108. {
    109. sql1 = "select * from allusers where username='"+username+"' and pwd='"+password+"'";
    110. }
    111. }
    112. List<HashMap> userlist1 = dao.select(sql1);
    113. if(userlist1.size()==1)
    114. {
    115. if (utype.equals("Ա��"))
    116. {
    117. request.getSession(). setAttribute("username", userlist1.get(0).get("yuangongbianhao"));
    118. request.getSession(). setAttribute("cx", utype);
    119. }
    120. else
    121. { if (utype.equals("���ž���"))
    122. {
    123. request.getSession(). setAttribute("username", userlist1.get(0).get("bumenbianhao"));
    124. request.getSession(). setAttribute("cx", utype);
    125. }
    126. else
    127. {
    128. request.getSession(). setAttribute("username", userlist1.get(0).get("username"));
    129. request.getSession(). setAttribute("cx", userlist1.get(0).get("cx"));
    130. }
    131. }
    132. gor("main.jsp", request, response);
    133. }else{
    134. request.setAttribute("error", "");
    135. go("/login.jsp", request, response);
    136. }
    137. }
    138. }
    139. if(ac.equals("uppass"))
    140. {
    141. String olduserpass = request.getParameter("ymm");
    142. String userpass = request.getParameter("xmm1");
    143. String copyuserpass = request.getParameter("xmm2");
    144. HashMap m = dao.getmaps("yonghuming",(String)request.getSession().getAttribute("username"), "yonghuzhuce");
    145. if(!(((String)m.get("mima")).equals(olduserpass)))
    146. {
    147. request.setAttribute("error", "");
    148. go("mod2.jsp", request, response);
    149. }else{
    150. //String id = (String)user.get("id");
    151. String sql = "update yonghuzhuce set mima='"+userpass+"' where yonghuming='"+(String)request.getSession().getAttribute("username")+"'";
    152. dao.commOper(sql);
    153. request.setAttribute("suc", "");
    154. go("mod2.jsp", request, response);
    155. }
    156. }

    上传控制器

    1. public class Upload extends HttpServlet {
    2. /**
    3. * Constructor of the object.
    4. */
    5. public Upload() {
    6. super();
    7. }
    8. /**
    9. * Destruction of the servlet. <br>
    10. */
    11. public void destroy() {
    12. super.destroy(); // Just puts "destroy" string in log
    13. // Put your code here
    14. }
    15. /**
    16. * The doGet method of the servlet. <br>
    17. *
    18. * This method is called when a form has its tag value method equals to get.
    19. *
    20. * @param request the request send by the client to the server
    21. * @param response the response send by the server to the client
    22. * @throws ServletException if an error occurred
    23. * @throws IOException if an error occurred
    24. */
    25. public void doGet(HttpServletRequest request, HttpServletResponse response)
    26. throws ServletException, IOException {
    27. this.doPost(request, response);
    28. }
    29. /**
    30. * The doPost method of the servlet. <br>
    31. *
    32. * This method is called when a form has its tag value method equals to post.
    33. *
    34. * @param request the request send by the client to the server
    35. * @param response the response send by the server to the client
    36. * @throws ServletException if an error occurred
    37. * @throws IOException if an error occurred
    38. */
    39. public void doPost(HttpServletRequest request, HttpServletResponse response)
    40. throws ServletException, IOException {
    41. StringBuffer sb = new StringBuffer(50);
    42. response.setContentType("application/x-msdownload;charset=GB2312");
    43. try {
    44. response.setHeader("Content-Disposition", new String(sb.toString()
    45. .getBytes(), "ISO8859-1"));
    46. } catch (UnsupportedEncodingException e1) {
    47. // TODO Auto-generated catch block
    48. e1.printStackTrace();
    49. }
    50. String filename = request.getParameter("filename");
    51. if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0){
    52. try {
    53. filename = new String(filename.getBytes("gb2312"), "ISO8859-1");
    54. } catch (UnsupportedEncodingException e) {
    55. // TODO Auto-generated catch block
    56. e.printStackTrace();
    57. }
    58. }
    59. else
    60. if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0){
    61. try {
    62. filename = URLEncoder.encode(filename, "gb2312");
    63. } catch (UnsupportedEncodingException e) {
    64. // TODO Auto-generated catch block
    65. }
    66. }
    67. response.setContentType("text/plain");
    68. response.setHeader("Location",filename);
    69. response.reset();
    70. response.setHeader("Cache-Control", "max-age=0" );
    71. response.setHeader("Content-Disposition", "attachment; filename=" + filename);
    72. try {
    73. BufferedInputStream bis = null;
    74. BufferedOutputStream bos = null;
    75. OutputStream fos = null;
    76. // File f = new File(request.getRealPath("/upfile/")+"/"+filename);
    77. //System.out.println(f);
    78. bis = new BufferedInputStream((InputStream)new FileInputStream(request.getRealPath("/upfile/")+"/"+filename));
    79. fos = response.getOutputStream();
    80. bos = new BufferedOutputStream(fos);
    81. int bytesRead = 0;
    82. byte[] buffer = new byte[5 * 1024];
    83. while ((bytesRead = bis.read(buffer)) != -1) {
    84. bos.write(buffer, 0, bytesRead);
    85. }
    86. bos.close();
    87. bis.close();
    88. fos.close();
    89. new Info().delPic(request.getRealPath("/upfile/")+"/", filename);
    90. } catch (Exception e) {
    91. }finally{
    92. }
    93. }
    94. /**
    95. * Initialization of the servlet. <br>
    96. *
    97. * @throws ServletException if an error occurs
    98. */
    99. public void init() throws ServletException {
    100. // Put your code here
    101. }
    102. }

     如果也想学习本系统,下面领取。回复:127ssh 

  • 相关阅读:
    Spring Boot + MyBatis-Plus 实现 MySQL 主从复制动态数据源切换
    java计算机毕业设计vue教学管理系统源码+数据库+系统+lw文档
    Greenplum-表分区
    AWS认证SAA-C03每日一题
    边读边递归
    技术路线扩容,韶音的雄心不止于骨传导耳机?
    【原创】CentOS9安装Zabbix6.4
    剑指Offer面试题解总结21-30
    Flink Batch Hash Aggregate
    IO多路复用--select,poll,epoll
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/125626876