Package org.apache.struts2.result
Class ServletActionRedirectResult
java.lang.Object
org.apache.struts2.result.StrutsResultSupport
org.apache.struts2.result.ServletRedirectResult
org.apache.struts2.result.ServletActionRedirectResult
- All Implemented Interfaces:
- Serializable,- Redirectable,- Result,- StrutsStatics,- ReflectionExceptionHandler
public class ServletActionRedirectResult
extends ServletRedirectResult
implements ReflectionExceptionHandler, Redirectable
 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. This means you can change your URL patterns at any point
 and your application will still work. It is strongly recommended that if you
 are redirecting to another action, you use this result rather than the
 standard redirect result.
 
See examples below for an example of how request parameters could be passed in.
This result type takes the following 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.
- 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.
- anchor - Optional. Also known as "fragment" or colloquially as "hash". You can specify an anchor for a result.
Example:
 
 <package name="public" extends="struts-default">
     <action name="login" class="...">
         <!-- Redirect to another namespace -->
         <result type="redirectAction">
             <param name="actionName">dashboard</param>
             <param name="namespace">/secure</param>
         </result>
     </action>
 </package>
 <package name="secure" extends="struts-default" namespace="/secure">
     <-- Redirect to an action in the same namespace -->
     <action name="dashboard" class="...">
         <result>dashboard.jsp</result>
         <result name="error" type="redirectAction">error</result>
     </action>
     <action name="error" class="...">
         <result>error.jsp</result>
     </action>
 </package>
 <package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters">
    <!-- Pass parameters (reportType, width and height) -->
    <!--
    The redirectAction url generated will be :
    /genReport/generateReport.action?reportType=pie&width=100&height=100#summary
    -->
    <action name="gatherReportInfo" class="...">
       <result name="showReportResult" type="redirectAction">
          <param name="actionName">generateReport</param>
          <param name="namespace">/genReport</param>
          <param name="reportType">pie</param>
          <param name="width">100</param>
          <param name="height">100</param>
          <param name="empty"></param>
          <param name="suppressEmptyParameters">true</param>
          <param name="anchor">summary</param>
       </result>
    </action>
 </package>
 
 - See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringstatic final Stringprotected Stringprotected StringFields inherited from class org.apache.struts2.result.ServletRedirectResultactionMapper, anchor, prependServletContext, requestParameters, statusCode, suppressEmptyParametersFields inherited from class org.apache.struts2.result.StrutsResultSupportDEFAULT_URL_ENCODING, parseLocationFields inherited from interface org.apache.struts2.StrutsStaticsACTION_MAPPING, HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION
- 
Constructor SummaryConstructorsConstructorDescriptionServletActionRedirectResult(String actionName) ServletActionRedirectResult(String actionName, String method) ServletActionRedirectResult(String namespace, String actionName, String method) ServletActionRedirectResult(String namespace, String actionName, String method, String anchor) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidexecute(ActionInvocation invocation) Implementation of the execute method from the Result interface.voidsetActionName(String actionName) Sets the action namevoidSets the methodvoidsetNamespace(String namespace) Sets the namespaceMethods inherited from class org.apache.struts2.result.ServletRedirectResultaddParameter, doExecute, handle, isPathUrl, sendRedirect, setActionMapper, setAnchor, setPrependServletContext, setQueryStringBuilder, setStatusCode, setSuppressEmptyParametersMethods inherited from class org.apache.struts2.result.StrutsResultSupportconditionalParse, conditionalParseCollection, getLastFinalLocation, getLocation, setEncode, setLocation, setParseMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.struts2.util.reflection.ReflectionExceptionHandlerhandle
- 
Field Details- 
DEFAULT_PARAM- See Also:
 
- 
actionName
- 
namespace
- 
method
 
- 
- 
Constructor Details- 
ServletActionRedirectResultpublic ServletActionRedirectResult()
- 
ServletActionRedirectResult
- 
ServletActionRedirectResult
- 
ServletActionRedirectResult
- 
ServletActionRedirectResult
 
- 
- 
Method Details- 
executeDescription copied from class:StrutsResultSupportImplementation of the execute method from the Result interface. This will call the abstract methodStrutsResultSupport.doExecute(String, ActionInvocation)after optionally evaluating the location as an OGNL evaluation.- Specified by:
- executein interface- Result
- Overrides:
- executein class- ServletRedirectResult
- Parameters:
- invocation- the execution state of the action.
- Throws:
- Exception- if an error occurs while executing the result.
- See Also:
 
- 
setActionNameSets the action name- Parameters:
- actionName- The name
 
- 
setNamespaceSets the namespace- Parameters:
- namespace- The namespace
 
- 
setMethodSets the method- Parameters:
- method- The method
 
- 
getProhibitedResultParams- Overrides:
- getProhibitedResultParamsin class- ServletRedirectResult
 
 
-