Struts2 Result Type

1、struts.xml

<struts> 
 <constant name="struts.devMode" value="true" />
 <package name="resultTypes" namespace="/r" extends="struts-default">
        
        <action name="r1">
            <result type="dispatcher">/r1.jsp</result>
        </action>
        <action name="r2">
            <result type="redirect">/r2.jsp</result>
        </action>
        <action name="r3">
            <result type="chain">r1</result>
        </action>
        <action name="r4">
            <result type="redirectAction">/r2</result>
        </action>
    </package>    

</struts>

2、index.jsp

<body>
Result类型
<ol>
	<li><a href="r/r1">dispatcher</li>
	<li><a href="r/r2">redirect</li>
	<li><a href="r/r3">chain</li>
	<li><a href="r/r4">redirectAction</li>
	
	<li>freemarker</li>
	<li>httpheader</li>
	<li>stream</li>
	<li>velocity</li>
	<li>xslt</li>
	<li>plaintext</li>
	<li>tiles</li>
</ol>
</body>

3、r1.jsp

<body>
r1
</body>

4.r2.jsp

<body>
r2
</body>


5、r3.jsp

<body>
r3
</body>


6、r4.jsp
<body>
r4
</body>



原文地址:https://www.cnblogs.com/lytwajue/p/7110609.html