所有result-type
<result-types> <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/> <result-type name="dispatcher" class="org.apache.struts2.result.ServletDispatcherResult" default="true"/> <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/> <result-type name="httpheader" class="org.apache.struts2.result.HttpHeaderResult"/> <result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/> <result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/> <result-type name="stream" class="org.apache.struts2.result.StreamResult"/> <result-type name="velocity" class="org.apache.struts2.result.VelocityResult"/> <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/> <result-type name="plainText" class="org.apache.struts2.result.PlainTextResult" /> <result-type name="postback" class="org.apache.struts2.result.PostbackResult" /> </result-types>
structs.xml
<action name="testResult" class="com.TestResultAction">
<!--默认转发 --> <result name="success" type="dispatcher">/success.jsp</result> <!-- 重定向--> <result name="login" type="redirect">/login.jsp</result> <!-- 重定向到一个 Action --> <!-- <result name="index" type="redirectAction"> <param name="actionName">testAction</param> <param name="namespace">/test</param> </result> --> <!-- 通过 redirect 的响应类型也可以便捷的实现 redirectAction 的功能! --> <result name="index" type="redirect">/test/testAction</result> <!-- 转发到一个 Action --> <!-- <result name="test" type="chain"> <param name="actionName">testAction</param> <param name="namespace">/test</param> </result> --> <!-- 不能通过 type=dispatcher 的方式转发到一个 Action --> <result name="test">/test/testAction</result> <package name="testPackage" namespace="/test" extends="struts-default"> <action name="testAction" class="com.TestAction"> <result>/success.jsp</result> </action> </package>