chain???
????? 用來處理Action鏈,將一個action的執行與另外一個配置好的action串連起來。用第一個action的getter方法和第二個action的setter方法來完成action之間屬性的復制。?
??? com.opensymphony.xwork2.ActionChainResult??
?
dispatcher?????
??? 用來轉向JSP頁面,這是默認的結果類型,如果在action配置中沒有配置其他的結果類型,它就會被使用???
??? org.apache.struts2.dispatcher.ServletDispatcherResult??
?
freemaker???
????? 處理FreeMarker模板???
????? org.apache.struts2.views.freemarker.FreemarkerResult??
?
httpheader???
????? 控制特殊HTTP行為的結果類型?????
???? org.apache.struts2.dispatcher.HttpHeaderResult??
?
redirect???
????? 重定向到一個URL?????
????? org.apache.struts2.dispatcher.ServletRedirectResult??
?
redirectAction???
??? 重定向到一個Action???
??? org.apache.struts2.dispatcher.ServletActionRedirectResult??
?
stream???
????? 向瀏覽器發送InputSream對象,通常用來處理文件下載,還可用于返回AJAX數據???
???? org.apache.struts2.dispatcher.StreamResult??
?
velocity?? stream?? redirectAction?? redirect?? httpheader?? freemaker? dispatcher chain?
????? 處理Velocity模板???
???? org.apache.struts2.dispatcher.VelocityResult??
?
xslt???
???? 處理XML/XLST模板???
???? org.apache.struts2.views.xslt.XSLTResult??
?
plainText???
????? 顯示原始文件內容,例如文件源代碼???
??? org.apache.struts2.dispatcher.PlainTextResult??
?
redirect-action?? plainText?? xslt?? velocity?? stream?? redirectAction?? redirect?? httpheader?? freemaker? dispatcher chain?
????? 重定向到一個Action???
???? org.apache.struts2.dispatcher.ServletActionRedirectResult??
?
plaintext???
???? 顯示原始文件內容,例如文件源代碼???
???? org.apache.struts2.dispatcher.PlainTextResult?
注:redirect與redirect-action區別
一、使用redirect需要后綴名 使用redirect-action不需要后綴名
二、type="redirect" 的值可以轉到其它命名空間下的action,而redirect-action只能轉到同一命名空下的 action,因此它可以省略.action的后綴直接寫action的名稱。
如:
<result name="success" type="redirect">viewTask.action</result>
<result name="success" type="redirect-action">viewTask</result>
附:redirect-action 傳遞參數
Xml代碼
- <action?name="enterpreinfo"?class="preinfoBusinessAction"????method="enterPreinfoSub">??
- ??<result?name="success"?type="redirect-action">??
- ?????showpreinfo?preinfo.order_number=${preinfo.order_number}&preinfo.company_name=${preinfo.company_name} ??
- ??</result>??
- ?<result?name="error"?type="redirect">??
- ????<param?name="location">/error.jsp</param>??
- ?</result>??
- </action>??
? ?因為使用了redirect-action,所以要注意不能將showpreinf?preinfo.order_number=${preinfo.order_number}寫成showpreinf.action?preinfo.order_number=${preinfo.order_number}
其中${}為EL表達式,獲取action:enterpreinfo中屬性的值;在這個配置文件里,多個參數的連接符使用了"&",但XML的語法規范,應該使用"&"代替"&",原理和HTML中的轉義相同.
redirect配置例子
<action ? name= "delete " ? class= "com.zeng.action.UserManageAction " ? method= "delete ">
? ? <result ? name= "success " ? type= "redirect-action ">
? ? ? ? <param ? name= "actionName "> list </param>
? ? ? ? <param ? name= "pageBean.pageNumber "> ${pageBean.pageNumber} </param>
? ? </result>
</action>
或者
<action ? name= "delete " ? class= "com.zeng.action.UserManageAction " ? method= "delete ">
? ? <result ? type= "redirect "> list.action?pageBean.pageNumber=${pageBean.pageNumber} </result>
</action>