基于javaweb+mysql的ssm员工绩效考核管理系统(JavaWeb JSP MySQL Servlet SSM SpringBoot Bootstrap Ajax)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
技术框架
JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL CSS JavaScript Bootstrap Ajax
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
登录、注册、退出、用户模块、公告模块、绩效模块、员工模块、薪酬模块的增删改查管理
eclipse/MyEclipse运行:
idea运行:
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", pb.getPageSize());
List list = (List) xinService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("xinList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("xin_list.jsp");
}
}
/**
* 拦截器
*/
public class LoginInterceptor implements HandlerInterceptor {
//@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
HttpSession session = request.getSession();
//移除错误提示
session.removeAttribute("alert_msg");
//登录拦截
String uri = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/"));
String[] access = new String[]{"login", "logout", "register", ".css", ".js", ".png", ".jpg", "validationCode"};
for (String action : access) {
if (uri.toLowerCase().contains(action.toLowerCase())) {
return true;
}
}
if (session.getAttribute("loginUser") == null) {
session.setAttribute("alert_msg", "错误:请先登录!");
response.sendRedirect("login.jsp");
return false;
}
return true;
}
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
Map<String, Object> params = new HashMap();
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) && user.getPassword().equals(password)) {//找到这个管理员了
request.getSession().setAttribute("loginUser", user);
request.getSession().setMaxInactiveInterval(Integer.MAX_VALUE);
request.getRequestDispatcher("userList").forward(request, response);
return;
}
}
request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
@RequestMapping("authRegister")
public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("username=" + username);
System.out.println("password=" + password);
Map<String, Object> params = new HashMap();
params.put("startIndex", 0);
params.put("pageSize", Long.MAX_VALUE);
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
request.getRequestDispatcher("register.jsp").forward(request, response);
return;
}
}
User vo = new User();
vo.setUsername(username);
public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
noticeService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeEdit")
public void edit(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
noticeService.update(vo);
this.redirectList(request, response);
}
/**
* 获取公告的详细信息(详情页面与编辑页面要显示该公告的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"noticeGet", "noticeEditPre"})
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = xinService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", pb.getPageSize());
List list = (List) xinService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("xinList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
response.sendRedirect("xin_list.jsp");
}
}
/**
* 拦截器
*/
public class LoginInterceptor implements HandlerInterceptor {
//@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o) throws Exception {
HttpSession session = request.getSession();
//移除错误提示
session.removeAttribute("alert_msg");
//登录拦截
String uri = request.getRequestURI().substring(request.getRequestURI().lastIndexOf("/"));
* @throws IOException
*/
@RequestMapping("xinEdit")
public void edit(Xin vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
xinService.update(vo);
this.redirectList(request, response);
}
/**
* 获取薪酬的详细信息(详情页面与编辑页面要显示该薪酬的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"xinGet", "xinEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Xin vo = xinService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询薪酬的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("xinList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = xinService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
@RequestMapping("empEdit")
public void edit(Emp vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
empService.update(vo);
this.redirectList(request, response);
}
/**
* 获取员工的详细信息(详情页面与编辑页面要显示该员工的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"empGet", "empEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Emp vo = empService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询员工的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("empList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = empService.list(params);
request.getSession().setAttribute("list", map.get("list"));
@Controller
@RequestMapping
public class JixiaoController {
@Autowired
private JixiaoService jixiaoService;
/**
* 增加绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoAdd")
public void add(Jixiao vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
jixiaoService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
jixiaoService.delete(Arrays.asList(id));
this.redirectList(request, response);
@Controller
@RequestMapping
public class NoticeController {
@Autowired
private NoticeService noticeService;
/**
* 增加公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeAdd")
public void add(Notice vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
noticeService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除公告
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("noticeDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
noticeService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑公告
*
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("xinAdd")
public void add(Xin vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
xinService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除薪酬
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("xinDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
xinService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑薪酬
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("xinEdit")
public void edit(Xin vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
xinService.update(vo);
this.redirectList(request, response);
}
/**
* 获取薪酬的详细信息(详情页面与编辑页面要显示该薪酬的详情)并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"xinGet", "xinEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Xin vo = xinService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
@Controller
@RequestMapping
public class JixiaoController {
@Autowired
private JixiaoService jixiaoService;
/**
* 增加绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoAdd")
public void add(Jixiao vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
jixiaoService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
jixiaoService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑绩效
*
* @param response
* @param request
* @throws IOException
*/
Emp vo = empService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询员工的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("empList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = empService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", pb.getPageSize());
List list = (List) empService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("empList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
pb.setList(list);
request.getSession().setAttribute("pageBean", pb);
request.getSession().setAttribute("list", pb.getList());
/**
* 增加用户
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("userAdd")
public void add(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
userService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除用户
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("userDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
userService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑用户
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("userEdit")
public void edit(User vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
userService.update(vo);
this.redirectList(request, response);
}
/**
* 获取用户的详细信息(详情页面与编辑页面要显示该用户的详情)并跳转回页面
*
* @param response
@Controller
public class AuthController extends HttpServlet {
@Autowired
private UserService userService;
@RequestMapping("authLogin")
public void login(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
String username = request.getParameter("username");
String password = request.getParameter("password");
String validationCode = request.getParameter("validationCode");
if (validationCode != null && !validationCode.equals(request.getSession().getAttribute("validationCode"))) {//验证码不通过
request.getSession().setAttribute("alert_msg", "错误:验证码不正确!");
request.getRequestDispatcher("login.jsp").forward(request, response);
return;
}
Map<String, Object> params = new HashMap();
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) && user.getPassword().equals(password)) {//找到这个管理员了
request.getSession().setAttribute("loginUser", user);
request.getSession().setMaxInactiveInterval(Integer.MAX_VALUE);
request.getRequestDispatcher("userList").forward(request, response);
return;
}
}
request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
@RequestMapping("authRegister")
public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
String username = request.getParameter("username");
* @param response
* @param request
* @throws IOException
*/
@RequestMapping({"jixiaoGet", "jixiaoEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Jixiao vo = jixiaoService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询绩效的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = jixiaoService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", pb.getPageSize());
List list = (List) jixiaoService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
private JixiaoService jixiaoService;
/**
* 增加绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoAdd")
public void add(Jixiao vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
jixiaoService.insert(vo);
this.redirectList(request, response);
}
/**
* 删除绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoDelete")
public void delete(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");
jixiaoService.delete(Arrays.asList(id));
this.redirectList(request, response);
}
/**
* 编辑绩效
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoEdit")
public void edit(Jixiao vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
jixiaoService.update(vo);
this.redirectList(request, response);
* @throws IOException
*/
@RequestMapping({"jixiaoGet", "jixiaoEditPre"})
public void get(HttpServletResponse response, HttpServletRequest request) throws IOException {
Serializable id = request.getParameter("id");//取出主键id
Jixiao vo = jixiaoService.get(id);
response.getWriter().println(com.alibaba.fastjson.JSONObject.toJSONString(vo));
}
/**
* 根据条件查询绩效的列表并跳转回页面
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("jixiaoList")
public void list(HttpServletResponse response, HttpServletRequest request) throws IOException {
this.redirectList(request, response);
}
/**
* 跳转到列表页面
*
* @param request
* @param response
*/
private void redirectList(HttpServletRequest request, HttpServletResponse response) throws IOException {
//查询列和关键字
String searchColumn = request.getParameter("searchColumn");
String keyword = request.getParameter("keyword");
Map<String, Object> params = new HashMap();//用来保存控制层传进来的参数(查询条件)
params.put("searchColumn", searchColumn);//要查询的列
params.put("keyword", keyword);//查询的关键字
Map<String, Object> map = jixiaoService.list(params);
request.getSession().setAttribute("list", map.get("list"));
Integer totalRecord = (Integer) map.get("totalCount");//根据查询条件取出对应的总记录数,用于分页
String pageNum = request.getParameter("pageNum");//封装分页参数
com.demo.util.PageBean<Object> pb = new com.demo.util.PageBean(Integer.valueOf(pageNum != null ? pageNum : "1"), totalRecord);
params.put("startIndex", pb.getStartIndex());
params.put("pageSize", pb.getPageSize());
List list = (List) jixiaoService.list(params).get("list");//根据分页参数startIndex、pageSize查询出来的最终结果list
pb.setServlet("jixiaoList");
pb.setSearchColumn(searchColumn);
pb.setKeyword(keyword);
}
}
request.getSession().setAttribute("alert_msg", "错误:用户名或密码错误!");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
@RequestMapping("authRegister")
public void register(HttpServletResponse response, HttpServletRequest request) throws IOException, ServletException {
String username = request.getParameter("username");
String password = request.getParameter("password");
System.out.println("username=" + username);
System.out.println("password=" + password);
Map<String, Object> params = new HashMap();
params.put("startIndex", 0);
params.put("pageSize", Long.MAX_VALUE);
List<User> list = (List<User>) userService.list(params).get("list");
for (User user : list) {
if (user.getUsername().equals(username) /*&& user.getPassword().equals(password)*/) {//说明该用户名已存在,必须换个用户名才能注册
request.getSession().setAttribute("alert_msg", "错误:用户名已存在!");
request.getRequestDispatcher("register.jsp").forward(request, response);
return;
}
}
User vo = new User();
vo.setUsername(username);
vo.setPassword(password);
//vo.setUserType("普通用户");//需要设置一个默认值
userService.insert(vo);
request.getSession().setAttribute("alert_msg", "注册成功!用户名:[" + username + "]");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
@RequestMapping("authLogout")
public void logout(HttpServletResponse response, HttpServletRequest request) throws IOException {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("loginUser");
if (user != null) {
session.removeAttribute("loginUser");
}
response.sendRedirect("login.jsp");
}
response.sendRedirect("user_list.jsp");
}
}
@Controller
@RequestMapping
public class EmpController {
@Autowired
private EmpService empService;
/**
* 增加员工
*
* @param response
* @param request
* @throws IOException
*/
@RequestMapping("empAdd")
public void add(Emp vo, HttpServletResponse response, HttpServletRequest request) throws IOException {
//调用Service层的增加(insert)方法
empService.insert(vo);
this.redirectList(request, response);
}