提交 b0a4be7c 编写于 作者: A Arjen Poutsma

Only respect RequestMappingInfos that have a pattern match in handleNoMatch

上级 ad2e0d45
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册