@RequestMapping(method = RequestMethod.GET, value = "list") public ModelAndView listPeople() { logger.debug("Received request to list persons"); ModelAndView mav = new ModelAndView(); List<Person> people = personDao.getPeople(); logger.debug("Person Listing count = " + people.size()); mav.addObject("people", people); mav.setViewName("list"); return mav; }
@RequestMapping(method = RequestMethod.GET, value = "edit") public ModelAndView editPerson(@RequestParam(value = "id", required = false) Long id) { logger.debug("Received request to edit person id : " + id); ModelAndView mav = new ModelAndView(); mav.setViewName("edit"); Person person = null; if (id == null) { person = new Person(); } else { person = personDao.find(id); } mav.addObject("person", person); return mav; }
@RequestMapping(method = RequestMethod.POST, value = "edit") public String savePerson(@ModelAttribute Person person) { logger.debug("Received postback on person " + person); personDao.save(person); return "redirect:list"; }