Add interceptor to resourceHandlerMapping
The resourceHandlerMapping in the MVC Java config is not configured with any interceptors, and in particular those added through the InterceptorRegistry, which are otherwise added to all other handler mapping beans created by the config. This means that the ResourceUrlProviderExposingInterceptor (added in 4.0) is also not used for resource requests. This change ensures the ResourceUrlProviderExposingInterceptor is configured on the resourceHandlerMapping. Issue: SPR-12279
This commit is contained in:
@@ -140,6 +140,9 @@ public class WebMvcConfigurationSupportExtensionTests {
|
||||
assertEquals(TestPathMatcher.class, handlerMapping.getPathMatcher().getClass());
|
||||
chain = handlerMapping.getHandler(new MockHttpServletRequest("GET", "/resources/foo.gif"));
|
||||
assertNotNull(chain.getHandler());
|
||||
assertEquals(Arrays.toString(chain.getInterceptors()), 2, chain.getInterceptors().length);
|
||||
// PathExposingHandlerInterceptor at chain.getInterceptors()[0]
|
||||
assertEquals(ResourceUrlProviderExposingInterceptor.class, chain.getInterceptors()[1].getClass());
|
||||
|
||||
handlerMapping = (AbstractHandlerMapping) this.config.defaultServletHandlerMapping();
|
||||
handlerMapping.setApplicationContext(this.context);
|
||||
|
||||
Reference in New Issue
Block a user