This is a common use to redirect action to display a page. Redirect Action Result: This redirect pattern is supported by Struts 2. The ActionMapper provided by the ActionMapperFactory is used to redirect the browser to a URL that invokes the specified action. You can see a simple implementation of this in the following struts 2 application.
Which is better redirect action result or servletredirectresult?
This result uses the ActionMapper provided by the ActionMapperFactory to redirect the browser to a URL that invokes the specified action and (optional) namespace. This is better than the ServletRedirectResult because it does not require you to encode the URL patterns processed by the ActionMapper in to your struts.xml configuration files.
What are the parameters to redirect an action?
Parameters actionName (default) – The name of the action that will be redirected to. namespace – Used to determine which namespace the action is in that we’re redirecting to. If namespace is null, the default will be the current namespace.
What happens if namespace is null in Apache Struts?
If namespace is null, the default will be the current namespace. suppressEmptyParameters – Optional boolean (defaults to false) that can prevent parameters with no values from being included in the redirect URL. parse – Boolean, true by default. If set to false, the actionName param will not be parsed for OGNL expressions.
How to avoid repetitive configuration in struts.xml?
One can also use annotations and the Convention plug-in to avoid repetitive configuration in struts.xml: Edit: Added a missing quote. I ended up subclassing Struts’ ServletRedirectResult and overriding it’s doExecute () method to do my logic before calling super.doExecute (). it looks like this: