コード例 #1
0
 @RequestMapping(method = RequestMethod.GET)
 public String index(ModelMap map) {
   for (User u : userService.getUserWithRole()) {
     System.out.println(u.toString());
   }
   map.addAttribute("users", userService.getUserWithRole());
   return "user/index";
 }
コード例 #2
0
 @RequestMapping(value = "update", method = RequestMethod.POST)
 public String update(
     @ModelAttribute(value = "User") User user, @Context HttpServletRequest request) {
   user.setUserId(Integer.parseInt(request.getParameter("id")));
   userService.update(user);
   return "redirect:/admin/user";
 }
コード例 #3
0
 @RequestMapping(value = "delete", method = RequestMethod.GET)
 public String delete(
     @ModelAttribute(value = "User") User user, @Context HttpServletRequest request) {
   int userId = Integer.parseInt(request.getParameter("id"));
   userService.delete(userId);
   return "redirect:/admin/user";
 }
コード例 #4
0
 @RequestMapping(value = "edit", method = RequestMethod.GET)
 public ModelAndView edit(
     @ModelAttribute(value = "User") User user, @Context HttpServletRequest request) {
   ModelAndView mv = null;
   int id = Integer.parseInt(request.getParameter("id"));
   User u = userService.getByUserId(id);
   if (u != null) {
     mv = new ModelAndView("user/edit");
     mv.addObject("role", roleService.getByRoleId(u.getRoleId()));
     mv.addObject("roles", roleService.getAll());
     mv.addObject("user", u);
   }
   return mv;
 }
コード例 #5
0
 @RequestMapping(value = "save", method = RequestMethod.POST)
 public String save(@ModelAttribute(value = "User") User user) {
   userService.insert(user);
   return "redirect:/admin/user";
 }