From 97441d054dc135dfcc18a90d81c6771a4f38239e Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 16 Oct 2014 17:20:35 -0400 Subject: [PATCH] Avoid HandlerMapping attribute in ResourceUrlProvider The use of the HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE in ResourceUrlProvider (as a way of saving lookup path determination) leads to incorrect results. For example when the request is forwarded the current requestUri may no longer be compariable to the value of the PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE. Also where the request is mapped using a pattern, the value of PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE is not the same as the lookup path. This change removes the use of the attribute from ResourceUrlProvider and instead always determines the lookup path when getForRequestUrl is called. Issue: SPR-12332 --- .../servlet/resource/ResourceUrlProvider.java | 23 ++++++--------- .../ResourceTransformerSupportTests.java | 5 ++-- .../ResourceUrlProviderJavaConfigTests.java | 28 ++----------------- 3 files changed, 12 insertions(+), 44 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 e9cf5d90a1..871772bf24 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 @@ -172,24 +172,17 @@ public class ResourceUrlProvider implements ApplicationListener