staffs = service.getStaffsByNameAndDepartment(queryName,queryDepartment);
61 | req.setAttribute("staffs", staffs);
62 | }
63 | }
64 | req.getRequestDispatcher("/WEB-INF/jsp/staff/info.jsp").forward(req, resp);
65 | break;
66 | }
67 | case "/staff/update":
68 | case "/staff/delete": {
69 | String errMessage = null;
70 | String idStr = req.getParameter("id");
71 | if (idStr != null && idStr.matches("[0-9]+")) {
72 | Staff staff = service.getStaff(Integer.parseInt(idStr));
73 | if (staff == null) {
74 | errMessage = "没有指定编号的员工!";
75 | } else {
76 | if ("/staff/update".equals(path)) {
77 | session.setAttribute("staff", staff);
78 | req.getRequestDispatcher("/WEB-INF/jsp/staff/editInfo.jsp").forward(req, resp);
79 | } else {
80 | errMessage = service.deleteStaff(staff.getId());
81 | if (errMessage == null) {
82 | session.setAttribute("message", "员工信息删除成功!");
83 | }
84 | }
85 | }
86 | } else {
87 | errMessage = "员工设定参数格式错误!";
88 | }
89 | if (errMessage != null) {
90 | session.setAttribute("errMessage", errMessage);
91 | }
92 | resp.sendRedirect("/staff/info");
93 | break;
94 | }
95 | case "/staff/save": {
96 | Staff staff = new Staff();
97 | staff.setId(Integer.parseInt(req.getParameter("id")));
98 | staff.setName(req.getParameter("name"));
99 | staff.setStaffDepartment(req.getParameter("staffDepartment"));
100 | staff.setStaffDuty(req.getParameter("staffDuty"));
101 | String errMessage = service.UpdateStaff(staff);
102 | System.out.println(errMessage);
103 | if (errMessage == null) {
104 | session.setAttribute("message", "员工信息保存成功!");
105 | } else {
106 | session.setAttribute("errMessage", errMessage);
107 | }
108 | resp.sendRedirect("/staff/info");
109 | break;
110 | }
111 | case "/staff/info":
112 | req.getRequestDispatcher("/WEB-INF/jsp/message.jsp").forward(req, resp);
113 | break;
114 | }
115 | }
116 |
117 | @Override
118 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
119 | doGet(req, resp);
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | Class structure
35 |
36 |
37 | Declaration redundancy
38 |
39 |
40 | Google Web Toolkit issues
41 |
42 |
43 | Inheritance issues
44 |
45 |
46 | Javadoc issues
47 |
48 |
49 | TestNG
50 |
51 |
52 |
53 |
54 | JavaDoc
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | dom4jrrrrr
109 |
110 |
115 |
116 |
117 |
118 |
119 |
120 | 1.6
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 | 1.6
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/web/WEB-INF/jsp/employStatus/statusInfo.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: master
4 | Date: 2020/5/12
5 | Time: 18:17
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
11 |
12 |
13 |
14 |
15 | Document
16 |
17 |
18 |
19 |
52 |
53 |
54 | 员工工作情况表
55 |
56 |
57 |
58 |
59 | | # |
60 | 月份 |
61 | 员工姓名 |
62 | 本月出勤情况 |
63 | 本月加班情况 |
64 | |
65 |
66 |
67 |
68 |
69 |
70 |
71 | | 1 |
72 | ${status.month} |
73 | ${status.name} |
74 | 本月出勤 ${status.attendDay} 天 |
75 | 本月加班 ${status.subsidyDay} 天 |
76 |
77 |
78 |
79 | |
80 |
81 |
82 | |
83 | 当前的查询结果,共 1 条员工工作记录信息
84 | |
85 |
86 |
87 |
88 |
89 |
90 | | ${varStatus.count} |
91 | ${status.month} |
92 | ${status.name} |
93 | 本月出勤 ${status.attendDay} 天 |
94 | 本月加班 ${status.subsidyDay} 天 |
95 |
96 |
97 |
98 | |
99 |
100 |
101 |
102 | |
103 | 当前的查询结果,共 ${fn:length(statuses)} 条员工工作记录信息
104 | |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/out/artifacts/web_war_exploded/WEB-INF/jsp/employStatus/statusInfo.jsp:
--------------------------------------------------------------------------------
1 | <%--
2 | Created by IntelliJ IDEA.
3 | User: master
4 | Date: 2020/5/12
5 | Time: 18:17
6 | To change this template use File | Settings | File Templates.
7 | --%>
8 | <%@ page contentType="text/html;charset=UTF-8" language="java" %>
9 | <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
10 | <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
11 |
12 |
13 |
14 |
15 | Document
16 |
17 |
18 |
19 |
52 |
53 |
54 | 员工工作情况表
55 |
56 |
57 |
58 |
59 | | # |
60 | 月份 |
61 | 员工姓名 |
62 | 本月出勤情况 |
63 | 本月加班情况 |
64 | |
65 |
66 |
67 |
68 |
69 |
70 |
71 | | 1 |
72 | ${status.month} |
73 | ${status.name} |
74 | 本月出勤 ${status.attendDay} 天 |
75 | 本月加班 ${status.subsidyDay} 天 |
76 |
77 |
78 |
79 | |
80 |
81 |
82 | |
83 | 当前的查询结果,共 1 条员工工作记录信息
84 | |
85 |
86 |
87 |
88 |
89 |
90 | | ${varStatus.count} |
91 | ${status.month} |
92 | ${status.name} |
93 | 本月出勤 ${status.attendDay} 天 |
94 | 本月加班 ${status.subsidyDay} 天 |
95 |
96 |
97 |
98 | |
99 |
100 |
101 |
102 | |
103 | 当前的查询结果,共 ${fn:length(statuses)} 条员工工作记录信息
104 | |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/src/util/JDBCUtils.java:
--------------------------------------------------------------------------------
1 | package util;
2 |
3 | import java.sql.*;
4 | import java.util.List;
5 | import java.util.Map;
6 | import java.util.ArrayList;
7 | import java.util.HashMap;
8 |
9 | public class JDBCUtils {
10 |
11 | private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
12 | private static final String DB_URL = "jdbc:mysql://localhost:3306/staff_manage?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false&allowPublicKeyRetrieval=true";
13 | private static final String DB_USERNAME = "user";
14 | private static final String DB_PASSWORD = "liangcanxin";
15 |
16 | static {
17 | try {
18 | Class.forName(DB_DRIVER);
19 | } catch (ClassNotFoundException e){
20 | System.err.println("DBTester Driver load failure...");
21 | }
22 | }
23 |
24 | /**
25 | * 使用Statement 执行 SQL-SELECT
26 | *
27 | * @param sql 语句
28 | * @return List Of map
29 | */
30 | public static List