diff --git a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java index b0a2b66e83b..46f704e4a10 100644 --- a/spring-core/src/main/java/org/springframework/util/ResourceUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ResourceUtils.java @@ -341,8 +341,11 @@ public abstract class ResourceUtils { int endIndex = urlFile.indexOf(WAR_URL_SEPARATOR); if (endIndex != -1) { - // Tomcat's "jar:war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt" + // Tomcat's "war:file:...mywar.war*/WEB-INF/lib/myjar.jar!/myentry.txt" String warFile = urlFile.substring(0, endIndex); + if (URL_PROTOCOL_WAR.equals(jarUrl.getProtocol())) { + return new URL(warFile); + } int startIndex = warFile.indexOf(WAR_URL_PREFIX); if (startIndex != -1) { return new URL(warFile.substring(startIndex + WAR_URL_PREFIX.length())); @@ -356,8 +359,6 @@ public abstract class ResourceUtils { /** * Create a URI instance for the given URL, * replacing spaces with "%20" URI encoding first. - *
Furthermore, this method works on JDK 1.4 as well, - * in contrast to the {@code URL.toURI()} method. * @param url the URL to convert into a URI instance * @return the URI instance * @throws URISyntaxException if the URL wasn't a valid URI