➊
@GetMapping
public String requestCartId(HttpServletRequest request) {
String sessionid = request.getSession(true).getId();
return "redirect:/cart/" + sessionid;
}
➋
@PostMapping
public @ResponseBody Cart create(@RequestBody Cart cart) {
return cartService.create(cart);
}
➌
@GetMapping("/{cartId}")
public String requestCartList(@PathVariable(value="cartId") String cartId, Model model) {
Cart cart = cartService.read(cartId);
model.addAttribute("cart", cart);
return "cart";
}
➍
@PutMapping("/{cartId}")
public @ResponseBody Cart read(@PathVariable(value="cartId") String cartId) {
return cartService.read(cartId);
}
}