Map arg resolver backs out if annotations present

Closes gh-21874
This commit is contained in:
Rossen Stoyanchev
2019-03-19 16:41:26 -04:00
parent a2fcf0a821
commit 5a3ff35215
4 changed files with 72 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +32,8 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*
* <p>A Map return value can be interpreted in more than one ways depending
* on the presence of annotations like {@code @ModelAttribute} or
* {@code @ResponseBody}. Therefore this handler should be configured after
* the handlers that support these annotations.
* {@code @ResponseBody}. As of 5.2 this resolver returns false if the
* parameter is annotated.
*
* @author Rossen Stoyanchev
* @since 3.1
@@ -42,7 +42,8 @@ public class MapMethodProcessor implements HandlerMethodArgumentResolver, Handle
@Override
public boolean supportsParameter(MethodParameter parameter) {
return Map.class.isAssignableFrom(parameter.getParameterType());
return Map.class.isAssignableFrom(parameter.getParameterType()) &&
parameter.getParameterAnnotations().length == 0;
}
@Override