从 Struts 2.1.3 开始,在 FilterDispatcher 的方法中使用了一个添加方法调用doFilter ()
来显示警告消息。
showDeprecatedWarning()
在控制台上打印消息。它只是一个 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);
}
但 Struts2 建议org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
使用org.apache.struts2.dispatcher.FilterDispatcher
.
web.xml 配置
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>