@RequestMapping(value = "/cars/delete", method = RequestMethod.POST) public String delete(int carId) { carDao.delete(carId); return "redirect:/cars"; }
@RequestMapping(value = "/cars/{id}", method = RequestMethod.POST) public String update(Car car, @PathVariable int id) { carDao.update(id, car); // car.id already set by binding return "redirect:/cars"; }
@RequestMapping(value = "/cars", method = RequestMethod.POST) public String add(Car car) { carDao.add(car); return "redirect:/cars"; }
@RequestMapping(value = "/cars/{id}", method = RequestMethod.GET) public String get(@PathVariable int id, Model model) { model.addAttribute("car", carDao.get(id)); return "carDetail"; }
@RequestMapping(value = "/cars", method = RequestMethod.GET) public String getAll(Model model) { model.addAttribute("cars", carDao.getAll()); return "carList"; }