首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Struts2.1跟Struts2.0的改变

2012-11-01 
Struts2.1和Struts2.0的改变2.1.*display-namestruts2 configuration/display-namefilterfilter-na

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>
?

?

?

?

热点排行