@RequestMapping(value = "/list") public String list(@RequestParam(value = "page", required = false) Integer page, Model model) { int pageNum = page != null ? page : DEFAULT_PAGE_NUM; Page<Person> paging = personService.findAll(pageNum, DEFAULT_PAGE_SIZE); model.addAttribute("page", paging); return "/person/list"; }
@RequestMapping(value = "/delete/{id}") public String delete( @RequestParam(value = "page", required = false) Integer page, @PathVariable("id") Integer id) { LOGGER.debug("delete id={}", id); personService.deleteById(id); return "redirect:/person/list"; }
@RequestMapping(value = "/edit", method = RequestMethod.POST) public String editOnSubmit(@Valid Person person, BindingResult bindingResult, Model model) { LOGGER.debug("edit person={}", person); if (bindingResult.hasErrors()) { LOGGER.warn("validation error={}", bindingResult.getModel()); model.addAllAttributes(bindingResult.getModel()); return "/person/form"; } personService.update(person); return "redirect:/person/list"; }
@RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public String edit(@PathVariable("id") Integer id, Model model) { Person person = personService.findById(id); model.addAttribute(person); return "/person/form"; }