diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java index 98c8341930..f487994f44 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java @@ -75,7 +75,9 @@ public class WebJarsResourceResolver extends AbstractResourceResolver { String path = chain.resolveUrlPath(resourceUrlPath, locations); if (path == null) { String webJarResourcePath = findWebJarResourcePath(resourceUrlPath); - return chain.resolveUrlPath(webJarResourcePath, locations); + if(webJarResourcePath != null) { + return chain.resolveUrlPath(webJarResourcePath, locations); + } } return path; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java index f80183304e..4fddeb734e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java @@ -107,6 +107,7 @@ public class WebJarsResourceResolverTests { assertNull(actual); verify(this.chain, times(1)).resolveUrlPath(file, this.locations); + verify(this.chain, never()).resolveUrlPath(null, this.locations); } @Test