上一篇我們把Struts2中的Action接收參數(shù)的內(nèi)容為大家介紹了,本篇我們就一起來(lái)簡(jiǎn)單學(xué)習(xí)一下Action的4種Result type類(lèi)型,分為:dispatcher(服務(wù)端頁(yè)面跳轉(zhuǎn));redirect(客戶(hù)端頁(yè)面跳轉(zhuǎn));chain(動(dòng)作鏈跳轉(zhuǎn));redirectAction(客戶(hù)端Action跳轉(zhuǎn)),當(dāng)然還有其他類(lèi)型,這里我們就以這四種為例為大家介紹一下,其他幾種大家有興趣單獨(dú)學(xué)習(xí)。下面我們一起來(lái)看一下上面四種的具體實(shí)現(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