Announcement Announcement Module
Collapse
No announcement yet.
RedirectView with attributes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RedirectView with attributes

    Is it possible to set attributes in one controller, and retreive the attributes in the next controller?

    Controller A is extended from a SimpleFormController, and in the onSubmit(), I use the request.setAttribute("name", "value"). The return statement:
    Code:
    return new ModelAndView( new RedirectView(this.getSuccessView()), modelMap );
    Controller B is extended from a ParameterizableViewController, and in the handleRequestInternal(), the request.getAttribute("name") returns a null.

    the part of the servlet mapping xml file looks like this:
    Code:
    <bean id="controllerA" class="com.blah.example.controllerA">
        <property name="formView">
            <value>controllerA</value>
        </property>
        <property name="successView">
            <value>controllerB</value>
        </property>
        <property name="sessionForm">
            <value>true</value>
        </property>
    </bean>
    
    <bean id="controllerB" class="com.blah.example.controllerB">
        <property name="viewName">
            <value>controllerB</value>
        </property>
    </bean>
    The purpose of this is so that the parameter does not have to be displayed in the URL.

  • #2
    The redirect view goes through the user's browser, so request scoped variables aren't going to work. If you really don't want the URL to have parameters then use session scoped attributes. Alternatively, use a querystring but add a only-once token to it to prevent user's from trying to resubmit or bookmark a dynamic page.

    Comment


    • #3
      I add static attributes

      and it works

      Code:
      		RedirectView redirection = new RedirectView&#40;getSuccessView&#40;&#41;,true&#41;;
      		redirection.addStaticAttribute&#40;"FOO","BAR"&#41;;
      		return new ModelAndView&#40;redirection&#41;;

      Comment

      Working...
      X