在struts.xml的配置中,經常會使用action标簽,在action标簽中有個result的子标簽是用來确定傳回結果和跳轉路徑的。
result标簽
-
name子标簽
與action标簽中的method的傳回值進行比較,用來确定跳轉的路徑。
-
<result-type>子标簽
type的屬性的取值在struts.xml中有定義。
<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
<result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
<result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
<result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
<result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
<result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
<result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/>
<result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
<result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
name | 代表 |
---|---|
dispatcher | 代表的是請求轉發,也是預設值。它一般用于從action跳轉到頁面。 |
chain | 相當于請求轉發,他一般情況下用于從一個action跳轉到另一個action。 |
redirect | 它代表的是重定向,一般用于用action跳轉到頁面。 |
redirectAction | 它代表的是重定向,一般用于從action到另一個action。 |
stream | 代表的是伺服器傳回的是一個流,一般用于下載下傳。 |