From d43dfc7bae5aa5e81bc51dfb26c1ae1ff1ecc52e Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Wed, 3 May 2017 21:58:59 +0200 Subject: [PATCH] Properly extract jar file from Tomcat war URL Issue: SPR-15485 --- .../io/support/PathMatchingResourcePatternResolver.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java index fcc4cfe41f..4e5da8b677 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java @@ -576,10 +576,13 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol // We'll also handle paths with and without leading "file:" prefix. String urlFile = rootDirURL.getFile(); try { - int separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR); + int separatorIndex = urlFile.indexOf(ResourceUtils.WAR_URL_SEPARATOR); + if (separatorIndex == -1) { + separatorIndex = urlFile.indexOf(ResourceUtils.JAR_URL_SEPARATOR); + } if (separatorIndex != -1) { jarFileUrl = urlFile.substring(0, separatorIndex); - rootEntryPath = urlFile.substring(separatorIndex + ResourceUtils.JAR_URL_SEPARATOR.length()); + rootEntryPath = urlFile.substring(separatorIndex + 2); // both separators are 2 chars jarFile = getJarFile(jarFileUrl); } else {