How to avoid the following error? I am implementing Spring-Security on Struts2, the application runs perfectly but the following message will be shown on server log.
Since Struts 2.1.3, an addition method call is used in doFilter ()
method of FilterDispatcher to display the warning message.
showDeprecatedWarning()
prints the message on the console. It just a System.out.println().
public void doFilter(....){
showDeprecatedWarning();
........
}
private void showDeprecatedWarning() {
String msg =
"\n\n" +
"***********************************************************************\n" +
"* WARNING!!! *\n" +
"* *\n" +
"* >>> FilterDispatcher <<< is deprecated! Please use the new filters! *\n" +
"* *\n" +
"* This can be a source of unpredictable problems! *\n" +
"* *\n" +
"* Please refer to the docs for more details! *\n" +
"* http://struts.apache.org/2.x/docs/webxml.html *\n" +
"* *\n" +
"***********************************************************************\n\n";
System.out.println(msg);
}
But Struts2 recommends to use org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
instead of org.apache.struts2.dispatcher.FilterDispatcher
.
web.xml configuration
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
I'd recommend following the link and doing what it says:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
The FilterDispatcher (org.apache.struts2.dispatcher.FilterDispatcher) is used in the early Struts2 development, and it’s deprecated since Struts 2.1.3.
If you are using Struts version >= 2.1.3, it’s always recommended to upgrade the new filter class – StrutsPrepareAndExecuteFilter (org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter).
for references
FilterDispatcher documentation
StrutsPrepareAndExecuteFilter documentation