I store a shopping cart instance during the checkout process in a session variable via org.springframework.web.bind.annotation.SessionAttributes:
@SessionAttributes({"shoppingCart"})
public class CheckoutController { ... }
However, when the checkout process is completed I want to store a fresh new ShoppingCart instance in the session.
I need something like:
sessionAttributes.set("shoppingCart", new ShoppingCart());
Which method can I use to achieve this task?
If you can access HttpServletRequest
, try with this
request.getSession().setAttribute("shoppingCart", new ShoppingCart());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With