I added a CORS filter to my application, but it does not seem to be executed (no prints).
The filter is this:
@Component
public class SimpleCORSFilter ex
First, it is uncommon to name the Root Spring Container xml file servlet-context.xml
. This name is normally used for the DispatcherServlet
configuration when using spring-mvc. You'd better use applicationContext.xml
.
But anyway, you should use a DelegatingProxyFilter
to allow proper initialization of the spring filter :
<filter>
<filter-name>simpleCORSFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
The DelegatingProxyFilter
will search in root context a bean named simpleCORSFilter
and will delegate the doFilter
method to it.