struts2在Web.xml中进行如下的配置(最基本的)
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
result的Type属性在不指定,默认情况下是dispatcher类型
type包括:
1.dispatcher 2.redirect 3.chain 4.redirectAction 5.freemarker
6.httpheader 7.stream 8.velocity 9.xslt 10.plaintext 11.tiles
最常用的也就如下配置的几种
<package name="default" namespace="/" extends="struts-default">
<action name="r1">
<!--利用服务器跳转,只能转到页面,不能到Action;类似于jsp.forword -->
<result type="dispatcher">/index.jsp</result>
</action>
<action name="r2">
<!-- 也只能转到视图,不能到Action -->
<result type="redirect">/Hello.jsp</result>
</action>
<action name="r3">
<!-- 可以转能到Action -->
<result type="chain"> r1</result>
</action>
<action name="r4">
<!-- 客户端跳转到另外的Action -->
<result type="redirectAction">r2</result>
</action>
</package>