Announcement Announcement Module
Collapse
No announcement yet.
Handling with Session on Spring MVC Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling with Session on Spring MVC

    Hi,

    I'm trying to handle with sessions on Spring, and after reading the reference manual and trying what it is exposed I'm not able to use sessions object.

    I need an object populated (bean) to be accessed on the whole web application. I have achieved if I use HttpSession object, but I want to do it by session bean scope.

    I declared session bean on application-context.xml:
    Code:
    <bean id="shoppingCart" class="com.toroliga.domain.ShoppingCart" scope="session">
    <aop:scoped-proxy/>
    </bean>
    Shoppingcart object has been annotated with @Scope("Session") and in the Controller it has been annotated @Scope("request"). If I populate ShoppingCart object, nothing happens. When I try to access to the object, it isn't populated.

    I have tried eliminating <aop:scoped-proxy> and on this way I can access to the data but only on the actions inside the actual Controller. If I try to access from other controller, the object is null.

    Could you explain me how to make a session bean with data already populated accessible from every part of my application?

    Thanks.
    Regards.
    JB

  • #2
    Hi, see this example.

    Comment


    • #3
      Judging from you description you are mixing a lot of things... First either use annotations or xml not both.. Also why have a session bean with scope request inside a controller that simply doesn't make sense..

      Remove the annotations and simply leave the xml simply inject this proxy in another object in which you want to use it.

      Comment

      Working...
      X