Servlet Filter url-mapping /* is not working on 404 errors

前端 未结 1 1768
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-24 16:27

I\'m using Resin Server & Apache 2.2 with virtual hosting. Here I\'m facing a big challenge in calling a concrete filter. I\'m having a generic Filter class to process all

相关标签:
1条回答
  • 2021-01-24 17:18

    Filters are by default dispatched on successful requests. They are by default not dispatched on erroneous requests. In order to dispatch them on erroneous requests as well, expand the filter mapping with the appropriate <dispatcher> elements:

    <filter-mapping>
        <filter-name>CorpFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    

    Note that when specifying custom dispatcher types and you'd like to keep the default REQUEST dispatcher, then you should be explicitly specifying it as well. Note that I also assume that the 404 is not handled by the web proxy (Apache HTTPD), but by the servlet container (Resin) itself, for obvious reasons.

    0 讨论(0)
提交回复
热议问题