javaWeb自己定義可排序過濾器注解,解決Servlet3.0下@WebFilter注解無法排序問題


com.lwl.anno

凝視類型 @WebFilterSort


須要用的jar包 http://download.csdn.net/detail/u013202238/9431110


用該注解注冊的Filter默認在部署描寫敘述符中的過濾器載入后載入,能夠使用isMatchAfter更改載入順序
為Filter排序注解,排序從1開始,1優先級最高
以url-pattern 過濾的最先運行,以servlet-name 過濾的在所有url-pattern運行后運行
在web.xml中設置參數
< context-param>
        < description>被掃描的過濾器的所在包< /description>
                < param-name>filterPackage< /param-name>
                < param-value>com.test.filter.pack< /param-value>
         < /context-param>
filterPackage  必填,包范圍越小越好
filterInitScanJar 選填
                  是否掃描jar包中的類,默覺得false不掃描,假設不打印能夠不配置該參數
filterInitDebug 選填
                     是否打印過濾器初始化信息(按排序順序),默認false不打印,假設不打印能夠不配置該參數

    • 必需元素概要

      所需元素  
      限定符和類型 必需的元素和說明
      int value
      排序優先級
    • 可選元素概要

      可選元素  
      限定符和類型 可選元素和說明
      boolean asyncSupported
      Declares whether the filter supports asynchronous operation mode.
      DispatcherType[] dispatcherTypes
      The dispatcher types to which the filter applies
      default {DispatcherType.REQUEST};
      java.lang.String displayName
      The display name of the filter,default ""
      java.lang.String filterName
      The name of the filter,default ""
      boolean isMatchAfter
      表示該過濾器相對於部署描寫敘述符中過濾器的順序 
      假設使用的參數為false,那么該過濾器映射將在部署描寫敘述符中描寫敘述的全部過濾器載入前進行載入, 
      假設為true( 默認 ),那么部署描寫敘述符中的過濾器將先被載入
      java.lang.String[] servletNames
      The names of the servlets to which the filter applies.
      java.lang.String[] urlPatterns
      The URL patterns to which the filter applies,default {"/*"}
    • 元素具體資料

      • value

        public abstract int value
        排序優先級
      • isMatchAfter

        public abstract boolean isMatchAfter
        表示該過濾器相對於部署描寫敘述符中過濾器的順序 
        假設使用的參數為false,那么該過濾器映射將在部署描寫敘述符中描寫敘述的全部過濾器載入前進行載入, 
        假設為true( 默認 ),那么部署描寫敘述符中的過濾器將先被載入
        默認值:
        true
      • displayName

        public abstract java.lang.String displayName
        The display name of the filter,default ""
        默認值:
        ""
      • filterName

        public abstract java.lang.String filterName
        The name of the filter,default ""
        默認值:
        ""
      • servletNames

        public abstract java.lang.String[] servletNames
        The names of the servlets to which the filter applies.,default {}
        默認值:
        {}
      • urlPatterns

        public abstract java.lang.String[] urlPatterns
        The URL patterns to which the filter applies,default {"/*"}
        默認值:
        "/*"
      • dispatcherTypes

        public abstract DispatcherType[] dispatcherTypes
        The dispatcher types to which the filter applies
        default {DispatcherType.REQUEST};
        默認值:
        <error>
      • asyncSupported

        public abstract boolean asyncSupported
        Declares whether the filter supports asynchronous operation mode.
        default  false
        另請參閱:
        javax.servlet.ServletRequest#startAsyncjavax.servlet.ServletRequest#startAsync(ServletRequest, ServletResponse)
        默認值:
        false


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM