FilterDispatcher is deprecated! - What is the replacement for FilterDispatcher?

前端 未结 3 599
孤城傲影
孤城傲影 2021-01-01 19:22

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.

3条回答
  •  耶瑟儿~
    2021-01-01 19:53

    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

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

提交回复
热议问题