Exemplo n.º 1
0
  @RequestMapping(
      value = {"", "/"},
      method = RequestMethod.POST)
  public String submitOrder(
      Model model,
      RedirectAttributes redirectAttributes,
      @Valid @ModelAttribute("order") Order order,
      BindingResult bindingResult) {
    if (bindingResult.hasErrors()) {
      model.addAttribute("order", order);
      return "form";
    }

    order = orderService.placeOrder(order);
    redirectAttributes.addFlashAttribute("message", "Order placed!");
    redirectAttributes.addAttribute("orderId", order.getId());
    return "redirect:/app/order/{orderId}";
  }
Exemplo n.º 2
0
 @RequestMapping(value = "{orderId}", method = RequestMethod.GET)
 public String showOrder(Model model, @PathVariable String orderId) {
   model.addAttribute("order", orderService.getOrder(orderId));
   return "vieworder";
 }