I have Spring 4.0 application
that does not use web.xml
.
I have the following webApplicationIntializer
in the spring project.
public class MyWebAppInitializer implements WebApplicationInitializer {
public static final String MAPPING_URL = "/*";
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext context =new AnnotationConfigWebApplicationContext();
servletContext.addListener(new ContextLoaderListener(context));
servletContext.addFilter("counterMetricsFilter", new DelegatingFilterProxy("counterMetricsFilter")).addMappingForUrlPatterns(null,
false, MAPPING_URL);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(
context));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping(MAPPING_URL);
}
}
I want the filtered to be applied to the following pattern.
"/v[1-9][0-9]*}"/*
everything except /v[1-9][0-9]*}"/foobar;
That is, the following will have filters
applied
/v2/helloworld
/v21/dummy
but the following url
patterns should be ignored
/foo/bar
/v2/foobar
/v21/foobar
That is the url
match start with v{2...}
followed by anything except foobar
for the filter
to be applied.
Thanks