zoukankan      html  css  js  c++  java
  • FilterDispatcher已被标注为过时解决办法

    一些struts2的教程都是比较早的,当我们基于较新版本的struts2来实现代码的时候,往往会出现一些问题.比如这个警告:FilterDispatcher isdeprecated!

    web.xml中的配置如下:

    [html] view plaincopy
     
    1. <filter>  
    2.          <filter-name>struts2</filter-name>  
    3.          <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>  
    4. </filter>  

    但是一运行起来就会出现,如图的警告:FilterDispatcher已经过时啦!请使用新的filter!

    打开警告里提到的链接,我们可以找到 FilterDispatcher Example(web.xml)

    [html] view plaincopy
     
    1. <web-app id="WebApp_9" version="2.4"   
    2.     xmlns="http://java.sun.com/xml/ns/j2ee"   
    3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    4.     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  
    5.   
    6.     <filter>  
    7.         <filter-name>struts2</filter-name>  
    8.         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
    9.         <init-param>  
    10.             <param-name>actionPackages</param-name>  
    11.             <param-value>com.mycompany.myapp.actions</param-value>  
    12.         </init-param>  
    13.     </filter>  
    14.   
    15.     <filter-mapping>  
    16.         <filter-name>struts2</filter-name>  
    17.         <url-pattern>/*</url-pattern>  
    18.     </filter-mapping>  
    19.   
    20.     <!-- ... -->  
    21.   
    22. </web-app>  

    FilterDispatcher Example并没有FilterDispatcher,而是变成了这一句:

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

     

    往下看,原来从>=2.1.3的版本开始,FilterDispatcher被标记为过时,取而代之的是新的

    StrutsPrepareAndExecuteFilter

     

    所以如果你的struts版本大于2.1.3时,filter配置要变成:

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

    如果是低于2.1.3版本,则还用本文最开始的配置即可。

  • 相关阅读:
    如何与多个线程的操作epoll fd
    谈谈Runtime类中的freeMemory,totalMemory,maxMemory等几个方法
    JAVA实现实用的ZIP压缩与解压
    HornetQ
    github
    实例解析shell子进程(subshell )
    Linux Shell Scripting Tutorial (LSST) v2.0
    java中byte数组与int类型的转换(两种方式)
    inotifywait实现目录监控
    子shell的$$
  • 原文地址:https://www.cnblogs.com/chengJAVA/p/3669641.html
Copyright © 2011-2022 走看看