Add headers to data binding values

Closes gh-32676
This commit is contained in:
rstoyanchev
2024-06-05 11:30:03 +01:00
parent 23160a43dd
commit f4f89aa2a4
6 changed files with 112 additions and 34 deletions

View File

@@ -3,8 +3,8 @@
[.small]#xref:web/webmvc/mvc-controller/ann-methods/modelattrib-method-args.adoc[See equivalent in the Servlet stack]#
The `@ModelAttribute` method parameter annotation binds request parameters onto a model
object. For example:
The `@ModelAttribute` method parameter annotation binds form data, query parameters,
URI path variables, and request headers onto a model object. For example:
[tabs]
======
@@ -27,6 +27,10 @@ Kotlin::
<1> Bind to an instance of `Pet`.
======
Form data and query parameters take precedence over URI variables and headers, which are
included only if they don't override request parameters with the same name. Dashes are
stripped from header names.
The `Pet` instance may be:
* Accessed from the model where it could have been added by a

View File

@@ -3,8 +3,8 @@
[.small]#xref:web/webflux/controller/ann-methods/modelattrib-method-args.adoc[See equivalent in the Reactive stack]#
The `@ModelAttribute` method parameter annotation binds request parameters onto a model
object. For example:
The `@ModelAttribute` method parameter annotation binds request parameters, URI path variables,
and request headers onto a model object. For example:
[tabs]
======
@@ -31,7 +31,11 @@ fun processSubmit(@ModelAttribute pet: Pet): String { // <1>
<1> Bind to an instance of `Pet`.
======
The `Pet` instance may be:
Request parameters are a Servlet API concept that includes form data from the request body,
and query parameters. URI variables and headers are also included, but only if they don't
override request parameters with the same name. Dashes are stripped from header names.
The `Pet` instance above may be:
* Accessed from the model where it could have been added by a
xref:web/webmvc/mvc-controller/ann-modelattrib-methods.adoc[@ModelAttribute method].