Struts2.1和Struts2.0的改变
2.1.*
<display-name>struts2 configuration</display-name><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>?
?
?
?
在Struts2.0.*中,在Web.xml中做如下配置便可加载Struts2.0.*
<!-- struts --><filter><filter-name>struts2</filter-name><filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter><filter-mapping><filter-name>struts2</filter-name><url-pattern>*.action</url-pattern><url-pattern>*.jsp</url-pattern></filter-mapping><!-- struts file upload --><filter><filter-name>struts-cleanup</filter-name><filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class></filter><filter-mapping><filter-name>struts-cleanup</filter-name><url-pattern>*.action</url-pattern></filter-mapping>
?在Struts2.1.*中用StrutsPrepareFilter、StrutsExecuteFilter来取代FilterDispatcher、ActionContextCleanUp
因此,在web.xml中配置如下 代码,便可 加载应用:
<filter> <filter-name>struts-prepare</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class> <init-param> <param-name>actionPackages</param-name> <param-value>org.apache.struts2.showcase.person</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts-prepare</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts-execute</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts-execute</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
?而且Struts2.1.*中可以用StrutsPrepareAndExecuteFilter整合了StrutsExecuteFilter、StrutsPrepareFilter两个过滤器,因此,便可做如下配置:
<display-name>struts2 configuration</display-name><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>*.action</url-pattern><url-pattern>*.jsp</url-pattern></filter-mapping>?
?
?
?