From b0a4be7cd112c25ae9a0f347fc6f3f1958e9275f Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 17 May 2011 10:07:36 +0000 Subject: [PATCH] Only respect RequestMappingInfos that have a pattern match in handleNoMatch --- .../RequestMappingHandlerMapping.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 66e794e28a..c8611a31f8 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -193,17 +193,21 @@ public class RequestMappingHandlerMapping extends AbstractHandlerMethodMapping consumableMediaTypes = new HashSet(); Set producibleMediaTypes = new HashSet(); for (RequestMappingInfo info : requestMappingInfos) { - if (!info.getMethods().match(request)) { - for (RequestMethod method : info.getMethods().getMethods()) { - allowedMethods.add(method.name()); + for (String pattern : info.getPatterns()) { + if (pathMatcher.match(pattern, lookupPath)) { + if (!info.getMethods().match(request)) { + for (RequestMethod method : info.getMethods().getMethods()) { + allowedMethods.add(method.name()); + } + } + if (!info.getConsumes().match(request)) { + consumableMediaTypes.addAll(info.getConsumes().getMediaTypes()); + } + if (!info.getProduces().match(request)) { + producibleMediaTypes.addAll(info.getProduces().getMediaTypes()); + } } } - if (!info.getConsumes().match(request)) { - consumableMediaTypes.addAll(info.getConsumes().getMediaTypes()); - } - if (!info.getProduces().match(request)) { - producibleMediaTypes.addAll(info.getProduces().getMediaTypes()); - } } if (!allowedMethods.isEmpty()) { throw new HttpRequestMethodNotSupportedException(request.getMethod(), allowedMethods);