I've been having some problems with ActionMessages
created during execution of an action which didn't display, and I found out that my problems were due to my forwards having redirect=true
in struts-config.xml.
Since the default behavior is redirect=false
, I've been thinking about which benefits can one have using redirect=true
and I couldn't find any answer. Does anyone know when and why redirect=true
should be used in action forwards?
If you specify redirect="true" , Struts uses a client-side redirect [ response. sendRedirect() ]. The JSP will be invoked by a new browser request, and any data stored in the old request will be lost.
The redirect result type calls the standard response. sendRedirect() method, causing the browser to create a new request to the given location.
An action issues a redirect to a URL. The actions pipeline is suspended after that Action completes its execution. The user is redirect to the URL along with a state parameter.
it prevents the 'double submit problem'
Never show pages in response to POST
Always load pages using GET
Navigate from POST to GET using REDIRECT
more on this here and here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With