Announcement
Announcement Module
Collapse
No announcement yet.
Redirect Request Parameters
Page Title Module
Move
Remove
Collapse
X
-
Redirect Request Parameters
How do I controll the request parameters that are sent with a RedirectView?Tags: None
-
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); }
Code:<bean id="resequencableListController" class="localhost.ResequencableListController"> ... <property name="successView" value="redirect:someOtherForm.html"/> </bean>
-
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?
Leave a comment:
Leave a comment: