Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Spring MVC and sessions

  1. #11
    Join Date
    Jul 2005
    Posts
    246

    Default

    Think of a controller as a servlet. Servlets are only loaded once, as are controllers.

    You can also store state in ThreadLocals - but this should not be designed in. Having to store state in the controller is, IMO, bad design. There are always exceptions where it is necessary, but it should not be part of the design.

    Think of the abstractions - a controller represents the application, an HttpSession represents the user. So where should the user's state be stored?

    Bob

  2. #12
    Join Date
    Jan 2006
    Posts
    14

    Default

    How do I activate the session form mode?

    Thanks in advance.

  3. #13
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    set sessionForm to true on your controller.

  4. #14
    Join Date
    Jul 2005
    Posts
    246

    Default

    Code:
    <bean id="myFormController" class="com.mycom.controller.MyFormController">
        <property name="commandName"><value>myCommand</value></property>
        <property name="commandClass"><value>com.mycom.command.MyCommand</value></property>
        <property name="sessionForm"><value>true</value></property>
    </bean>
    Bob

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •