Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RequestMapping(value = "/hotel/edit", method = RequestMethod.GET)
- public String editHotel(@RequestParam(required = false) Long hotelId, Model model) {
- HotelDTO hotel;
- if (hotelId==null)
- hotel = new HotelDTO();
- else
- hotel = hotelService.findHotel(hotelId);
- model.addAttribute("hotel", hotel);
- return "hotel-edit";
- }
- @RequestMapping(value = "/hotel/edit/submit", method = RequestMethod.POST)
- public String submitHotel(@ModelAttribute HotelDTO hotel, UriComponentsBuilder uriBuilder) {
- if(hotel.getId() == 0)
- hotelService.addHotel(hotel);
- else
- hotelService.updateHotel(hotel);
- return "redirect:" + uriBuilder.path("/hotels").build();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement