mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 22:19:03 +00:00
Only respect RequestMappingInfos that have a pattern match in handleNoMatch
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4312 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
+13
-9
@@ -193,17 +193,21 @@ public class RequestMappingHandlerMapping extends AbstractHandlerMethodMapping<R
|
||||
Set<MediaType> consumableMediaTypes = new HashSet<MediaType>();
|
||||
Set<MediaType> producibleMediaTypes = new HashSet<MediaType>();
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user