From 24d77f3272179a50e5bbd8b834f845bc09973df8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 14 Oct 2014 14:18:04 -0400 Subject: [PATCH] Prepend leading slash in ResourceUrlProvider The getForRequestUrl method of ResourceUrlProvider uses the HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE attribute to determine the relevant portion of the resource URL path. However there are cases when that attribute may not have a leading (e.g. when the current URL was matched to a prefix-based pattern and hence extracted via PathMatcher#extractPathWithinPattern), which interferes with the matching of resource URL paths to patterns. This change ensures a leading slash is present Issue: SPR-12281 --- .../servlet/resource/ResourceUrlProvider.java | 3 +++ .../ResourceHttpRequestHandlerTests.java | 20 +++++++++---------- .../ResourceTransformerSupportTests.java | 2 +- .../ResourceUrlProviderJavaConfigTests.java | 15 +++++++++++++- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 41dc298aac..e9cf5d90a1 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -179,6 +179,9 @@ public class ResourceUrlProvider implements ApplicationListener