rutsPrepareFilter和StrutsExecuteF

rutsPrepareFilter和StrutsExecuteF

我正在学习Struts2。我有一个问题要问,这两个Filter实现之间有什么区别

<filter>
    <filter-name>struts-prepare</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
    <filter-name>struts-execute</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts-prepare</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
    <filter-name>struts-execute</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>




<filter>
    <filter-name>struts</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>struts</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>


两者是否具有相同的行为。我的看法是两者都不同,但我没有用哪个词。

谢谢

最佳答案

它们完全相同,StrutsPrepareAndExecuteFilter是StrutsPrepareFilter和StrutsExecuteFilter的结合,请看这里的实现


StrutsPrepareFilter
StrutsExecuteFilter
StrutsPrepareAndExecuteFilter


仅通知:

Handles both the preparation and execution phases of the Struts dispatching
process.
This filter is better to use when you don't have another filter that needs
access to action context information, such as Sitemesh.

09-26 07:59