org.apache.struts2.dispatcher
类 ServletActionRedirectResult

java.lang.Object
  继承者 org.apache.struts2.dispatcher.StrutsResultSupport
      继承者 org.apache.struts2.dispatcher.ServletRedirectResult
          继承者 org.apache.struts2.dispatcher.ServletActionRedirectResult
所有已实现的接口:
com.opensymphony.xwork2.Result, com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler, Serializable, StrutsStatics

public class ServletActionRedirectResult
extends ServletRedirectResult
implements com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler

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:

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>


 
 

另请参见:
ActionMapper, 序列化表格

字段摘要
static String DEFAULT_PARAM
           
 
从接口 org.apache.struts2.StrutsStatics 继承的字段
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT
 
构造方法摘要
ServletActionRedirectResult()
           
ServletActionRedirectResult(String actionName)
           
ServletActionRedirectResult(String actionName, String method)
           
ServletActionRedirectResult(String namespace, String actionName, String method)
           
ServletActionRedirectResult(String namespace, String actionName, String method, String anchor)
           
 
方法摘要
 void execute(com.opensymphony.xwork2.ActionInvocation invocation)
          Implementation of the execute method from the Result interface.
 void setActionName(String actionName)
          Sets the action name
 void setMethod(String method)
          Sets the method
 void setNamespace(String namespace)
          Sets the namespace
 
从类 org.apache.struts2.dispatcher.ServletRedirectResult 继承的方法
addParameter, handle, setActionMapper, setAnchor, setPrependServletContext, setStatusCode, setSuppressEmptyParameters, setUrlHelper
 
从类 org.apache.struts2.dispatcher.StrutsResultSupport 继承的方法
getLastFinalLocation, getLocation, setEncode, setLocation, setParse
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler 继承的方法
handle
 

字段详细信息

DEFAULT_PARAM

public static final String DEFAULT_PARAM
另请参见:
常量字段值
构造方法详细信息

ServletActionRedirectResult

public ServletActionRedirectResult()

ServletActionRedirectResult

public ServletActionRedirectResult(String actionName)

ServletActionRedirectResult

public ServletActionRedirectResult(String actionName,
                                   String method)

ServletActionRedirectResult

public ServletActionRedirectResult(String namespace,
                                   String actionName,
                                   String method)

ServletActionRedirectResult

public ServletActionRedirectResult(String namespace,
                                   String actionName,
                                   String method,
                                   String anchor)
方法详细信息

execute

public void execute(com.opensymphony.xwork2.ActionInvocation invocation)
             throws Exception
从类 StrutsResultSupport 复制的描述
Implementation of the execute method from the Result interface. This will call the abstract method StrutsResultSupport.doExecute(String, ActionInvocation) after optionally evaluating the location as an OGNL evaluation.

指定者:
接口 com.opensymphony.xwork2.Result 中的 execute
覆盖:
ServletRedirectResult 中的 execute
参数:
invocation - the execution state of the action.
抛出:
Exception - if an error occurs while executing the result.
另请参见:
Result.execute(com.opensymphony.xwork2.ActionInvocation)

setActionName

public void setActionName(String actionName)
Sets the action name

参数:
actionName - The name

setNamespace

public void setNamespace(String namespace)
Sets the namespace

参数:
namespace - The namespace

setMethod

public void setMethod(String method)
Sets the method

参数:
method - The method