diff -r d1036b776eee -r a94b172c3a93 src/java/de/uapcore/lightpit/AbstractLightPITServlet.java --- a/src/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sat Dec 30 20:41:55 2017 +0100 +++ b/src/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sun Dec 31 17:43:39 2017 +0100 @@ -73,6 +73,12 @@ /** * Invocation mapping gathered from the {@link RequestMapping} annotations. + * + * Paths in this map must always start with a leading slash, although + * the specification in the annotation must not start with a leading slash. + * + * The reason for this is the different handling of empty paths in + * {@link HttpServletRequest#getPathInfo()}. */ private final Map> mappings = new HashMap<>(); @@ -145,9 +151,11 @@ if (params.length == 2 && HttpServletRequest.class.isAssignableFrom(params[0]) && HttpServletResponse.class.isAssignableFrom(params[1])) { + + final String requestPath = "/"+mapping.get().requestPath(); if (mappings.computeIfAbsent(mapping.get().method(), k -> new HashMap<>()). - putIfAbsent(mapping.get().requestPath(), + putIfAbsent(requestPath, (req, resp) -> invokeMapping(method, req, resp)) != null) { LOG.warn("{} {} has multiple mappings", mapping.get().method(), @@ -157,7 +165,7 @@ LOG.info("{} {} maps to {}", mapping.get().method(), - mapping.get().requestPath(), + requestPath, method.getName() ); } else { @@ -219,7 +227,7 @@ private Optional findMapping(HttpMethod method, HttpServletRequest req) { return Optional.ofNullable(mappings.get(method)).map( - (rm) -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("")) + (rm) -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("/")) ); }