Support name attribute in @ModelAttribute in WebFlux

Prior to this commit, the `name` attribute in @ModelAttribute was not
supported when using WebFlux. This is because MethodParameter was used
instead of SynthesizingMethodParameter when retrieving the
@ModelAttribute annotation. In other words, @AliasFor was not honored
because the annotation was not synthesized. Consequently, only the
`value` attribute was supported in WebFlux when specifying a custom name
via @ModelAttribute.

This commit fixes this by using SynthesizingMethodParameter to retrieve
the @ModelAttribute annotation.

Closes gh-28423
This commit is contained in:
Sam Brannen
2022-05-07 17:14:59 +02:00
parent 64c96c579d
commit 7dd622bdb2
2 changed files with 6 additions and 4 deletions

View File

@@ -180,7 +180,7 @@ class ErrorsMethodArgumentResolverTests {
@SuppressWarnings("unused")
void handleWithCustomModelAttributeName(
@ModelAttribute("custom") Foo foo,
@ModelAttribute(name = "custom") Foo foo,
Errors errors,
@ModelAttribute Mono<Foo> fooMono,
BindingResult bindingResult,