Announcement Announcement Module
Collapse
No announcement yet.
Redirect Request Parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redirect Request Parameters

    How do I controll the request parameters that are sent with a RedirectView?

  • #2
    Redirect Request Parameters

    I would like to be able to modify my successViews in the following ways (preferably both).

    <bean id="resequencableListController"
    class="localhost.ResequencableListController">
    <property name="resequencableListBo" ref="resequencableListBo"/>
    <property name="formView"
    value="resequencableList"/>
    <property name="successView"
    value="redirect:someOtherForm.html?otherId=${other Id}"/>
    </bean>

    In the previous example, I'd like "${otherId}" to be replaced with the request parameter "otherId". Or,

    <form method="post" action="/resequencableList.html">
    <input type="hidden" name="successView" value="redirect:someOtherForm.html?otherId=${other Id}"/>
    ...
    </form>

    In the previous example, I'd like the request attribute "successView" to be used as the successView.

    Which classes should I update to make these changes globally?

    Comment


    • #3
      Hi,

      When you use redirect, Spring will take your model and add it to the request as request parameters, so you could create a new model and add 'otherId' to it.

      For example:
      Code:
      import java.util.HashMap;
      import javax.servlet.http.*;
      import org.springframework.validation.BindException;
      import org.springframework.web.bind.RequestUtils;
      import org.springframework.web.servlet.ModelAndView;
      ...
      protected ModelAndView onSubmit(HttpServletRequest request,	
          HttpServletResponse response, Object command, BindException errors)  
          throws Exception {
      
          Map model = new HashMap();
          model.put("otherId", RequestUtils.getLongParameter(request, "otherId");
          return new ModelAndView(getSuccessView(), model);
      }
      The successview for your controller should be defined as follows:

      Code:
      <bean id="resequencableListController"
        class="localhost.ResequencableListController">
      ...
      <property name="successView" value="redirect:someOtherForm.html"/>
      </bean>

      Comment

      Working...
      X