web.xml <filter-mapping> not working when using <servlet-name>
I have a web.xml that has this in it:
<filter>
<description>CASRebroadcastFilter</description>
<filter-name>CASRebroadcastFilter</filter-name>
<filter-class>edu.utah.acs.tek.filters.CASSingleSignOutRebroadcast</filter-class>
</filter>
(... more CAS-filters)
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter-mapping>
<filter-name>CASRebroadcastFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
(... more CAS-filter-mappings and the rest of my web.xml...)
Environment: Spring 2.5, Glassfish 2.1
And this works as expected -- namely, the CASRebroadcastFilter intercepts and handles the appropriate calls and allows everything else to pass through.
But if I change my filter-mapping to this:
<filter-mapping>
<filter-name>CASRebroadcastFilter</filter-name>
<servlet-name>dispatcher</servlet-name>
</filter-mapping>
It doesn't work. And by "doesn't work" I mean exactly that: everything passes through the CASRebroadcastFilter as if it's just not there and not a single error or other thing 开发者_运维问答is output.
It's as if the <servlet-name>
tag just doesn't work within the context of some aspect of my environment.
Has anyone else seen this or know what might be causing this?
Could be due to the fact that you change the ordering of filters when you set it using servlet-name. The servlet container will run filters in the order they are configured in web.xml, first those using a url-pattern then those using servlet-name. So a filter using url-pattern is always executed before one using servlet-name.
So by changing it to using servlet-name you're effectively placing it after all filters using url-pattern.
精彩评论