diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java index ace9446dd9..cb10f1b48a 100644 --- a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java +++ b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java @@ -36,6 +36,12 @@ import javax.servlet.ServletContext; import java.net.MalformedURLException; import java.util.*; +import java.net.URL; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** *
@@ -313,16 +319,18 @@ protected Result findResult(String path, String resultCode, String ext, ActionCo try { LOG.trace("Checking ServletContext for {}", path); - if (servletContext.getResource(path) != null) { - LOG.trace("Found"); + URL resource = servletContext.getResource(path); + if (resource != null && resource.getPath().endsWith(path)) { + LOG.trace("Found resource {}", resource); return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext); } LOG.trace("Checking ClassLoader for {}", path); String classLoaderPath = path.startsWith("/") ? path.substring(1, path.length()) : path; - if (ClassLoaderUtil.getResource(classLoaderPath, getClass()) != null) { - LOG.trace("Found"); + resource = ClassLoaderUtil.getResource(classLoaderPath, getClass()); + if (resource != null && resource.getPath().endsWith(classLoaderPath)) { + LOG.trace("Found resource {}", resource); return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext); } } catch (MalformedURLException e) {