上一篇我們把Struts2中的Action接收參數(shù)的內(nèi)容為大家介紹了,本篇我們就一起來簡單學(xué)習(xí)一下Action的4種Result type類型,分為:dispatcher(服務(wù)端頁面跳轉(zhuǎn));redirect(客戶端頁面跳轉(zhuǎn));chain(動作鏈跳轉(zhuǎn));redirectAction(客戶端Action跳轉(zhuǎn)),當(dāng)然還有其他類型,這里我們就以這四種為例為大家介紹一下,其他幾種大家有興趣單獨學(xué)習(xí)。下面我們一起來看一下上面四種的具體實現(xiàn),首先是我們的配置文件:
<package name="resultFilter" namespace="/resultFilter" extends="struts-default"> <!-- http://localhost:8080/Struts/resultFilter/default --> <action name="default" class="com.edu.action.ResultFilter"> <result name="success">/default.jsp</result> </action> <!-- http://localhost:8080/Struts/resultFilter/dispatcher 服務(wù)端跳轉(zhuǎn)--> <action name="dispatcher" class="com.edu.action.ResultFilter" method="Dispatcher"> <result name="success" type="dispatcher">/dispatcher.jsp</result> </action> <!-- http://localhost:8080/Struts/resultFilter/redirect