private void updateUI(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { User u = WebUtils.request2Bean(request, User.class); User user = service.findUser(u); request.setAttribute("user", user); List<Role> rlist = service.getAllRole(); request.setAttribute("rlist", rlist); request.getRequestDispatcher("/security/updateuser.jsp").forward(request, response); }
private void update(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { User u = WebUtils.request2Bean(request, User.class); User user = service.findUser(u); String[] role_ids = request.getParameterValues("rid"); Set<Role> set = new HashSet<Role>(); for (String rid : role_ids) { Role role = new Role(); role.setId(Integer.parseInt(rid)); set.add(role); } user.setRole(set); service.updateUser(user); request.setAttribute("message", "更新成功"); } catch (Exception e) { e.printStackTrace(); request.setAttribute("message", "更新失败"); } request.getRequestDispatcher("/message.jsp").forward(request, response); }
private void getAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<User> list = service.getAllUser(); request.setAttribute("list", list); request.getRequestDispatcher("/security/listuser.jsp").forward(request, response); }