Spring store object in session

@Component
@Scope("session")
public class Cart { .. }

and then

@Inject
private Cart cart;

should work, if it is declared in the web context (dispatcher-servlet.xml). An alternative option is to use the raw session and put your cart object there:

@RequestMapping(..)
public String someControllerMethod(HttpSession session) {
    session.setAttribute(Constants.CART, new Cart());
    ...
    Cart cart = (Cart) session.getAttribute(Constants.CART);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)