コード例 #1
0
 @RequestMapping(value = "delete", method = RequestMethod.GET)
 public String delete(@RequestParam("id") int id) {
   try {
     service.delete(id);
   } catch (NotFoundException e) {
     e.printStackTrace();
   }
   return "redirect:/menu";
 }
コード例 #2
0
 @RequestMapping(value = "/update", method = RequestMethod.GET)
 public String editForUpdate(Model model, @RequestParam("id") int id) {
   try {
     model.addAttribute("menuMeal", service.get(id));
   } catch (NotFoundException e) {
     e.printStackTrace();
   }
   return "menuMealEdit";
 }
コード例 #3
0
  @RequestMapping(value = "/buy", method = RequestMethod.GET)
  public String editForBuy(
      Model model, @RequestParam("id") int id, @RequestParam("menuId") int menuId) {
    Meal meal = new Meal();
    MenuMeal menuMeal = new MenuMeal();
    try {
      menuMeal = service.get(id);
    } catch (NotFoundException e) {
      e.printStackTrace();
    }
    meal.setDescription(menuMeal.getDescription());
    meal.setCost(menuMeal.getCost());

    model.addAttribute("meal", meal);
    model.addAttribute("menuId", menuId);
    model.addAttribute("userList", userService.getAll());
    return "/mealEdit";
  }
コード例 #4
0
 @RequestMapping(method = RequestMethod.POST)
 public String createOrUpdate(@ModelAttribute("menuMeal") MenuMeal menuMeal) {
   service.save(menuMeal);
   return "redirect:/menu";
 }