GH-1240 - Add support for @ModelAttribute. - #2360
Conversation
33d9dbe to
f07181f
Compare
Method parameters annotated with @ModelAttribute now contribute to the links built for the handler method: every bindable property renders its own request parameter, following RFC6570's form-style query expansion, with unpopulated ones left as template variables. Only explicitly annotated parameters are considered, as link building has no argument resolver chain to defer to and therefore cannot tell an unannotated command object apart from the likes of HttpServletRequest or Pageable. Signed-off-by: Kim Tae Eun <snowykte0426@naver.com>
f07181f to
2156dc0
Compare
|
This has been rebased onto current What it does nowSpring MVC binds a I verified the round trip end to end: expanding the rendered template via ApproachRather than a parallel mechanism, this uses the extension points that were already there:
On the affordance side: I did have Behaviour worth knowingA property is bindable if it is writable (or a record component, as those bind through the canonical constructor) and resolves to a simple type or a collection of such. Type variables are resolved against the owning type, so A property whose name is already taken by a A failing getter is treated as an absent value rather than propagating, so a form object with a lazily-computing or defensive getter cannot turn link assembly into an exception. Two limitations are documented rather than fixed. A primitive property cannot express "unset", so Deliberately out of scopeImplicit The composite Tests and docs
@odrotbohm — this has been sitting a while and no longer resembles what was originally submitted, so it may be worth a fresh look rather than reading the old diff. Two things I would especially value your call on: whether the declared |
Adds support for Spring MVC's
@ModelAttributein link building, resolving #1240.Spring MVC binds a
@ModelAttributeparameter from the individual request parameters matching the properties of its type. Link building now mirrors that, using RFC6570's form-style query expansion, with unpopulated properties left as template variables:Implemented through the existing extension points —
@ModelAttributeis registered inWebHandler'sHandlerMethodParameters.ANNOTATIONSandHandlerMethodParameter.FACTORYalongside@RequestParamand@PathVariable. SinceWebHandlerbacks both stacks, WebFlux is covered too. No new public API.Only parameters explicitly annotated with
@ModelAttributeare considered, and only the form-style expansion is implemented. See the discussion below for the reasoning.