FilterDispatcher has been marked as obsolete solutions >>> FilterDispatcher

Some Struts 2 tutorial is relatively early , when we are on a newer version of struts2 time to implement the code , often there will be some problems . For example, this warning: FilterDispatcher isdeprecated!


In web.xml configuration as follows :

<filter>  
    <filter-name>struts2</filter-name>  
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
</filter>  

But there will be a run up, as shown in the warning: FilterDispatcher outdated it! Please use the new filter!


Open link warning mentioned, we can find FilterDispatcher Example (web.xml)

<web-app id="WebApp_9" version="2.4" 
	xmlns="http://java.sun.com/xml/ns/j2ee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
        <init-param>
        	<param-name>actionPackages</param-name>
        	<param-value>com.mycompany.myapp.actions</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- ... -->

</web-app>

This FilterDispatcher Example did not FilterDispatcher, but became this sentence:

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter


Look down from the original> = 2.1.3 version of the beginning, FilterDispatcher is marked as obsolete, replaced by a new

StrutsPrepareAndExecuteFilter


So if your struts version greater than 2.1.3 When, filter configured to become:

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter。

If it is lower than version 2.1.3, you can also use the beginning of this article can be configured.

Reproduced in: https: //www.cnblogs.com/Codenewbie/p/3378650.html

Guess you like

Origin blog.csdn.net/weixin_34384557/article/details/93448200