Browse Source

Work around code example callout bug

This commit adds callouts to two sets of Java/Kotlin code examples in
the @ModelAttribute section for Web MVC in order to work around the
"Code example has callout from a different code example" bug.

This also aligns the Web MVC examples with the WebFlux examples.

As a side note, the bug can also be seen in the WebFlux documentation
if the callouts are removed from the first Java/Kotlin examples in the
@ModelAttribute section for WebFlux. Thus it appears to be a general
issue related to examples within a given section of the documentation
when some examples have callouts and others do not, likely due to a bug
in the Javascript that provides this feature.

See gh-29505
pull/29516/head
Sam Brannen 2 years ago
parent
commit
ac7d428a62
  1. 13
      framework-docs/src/docs/asciidoc/web/webmvc.adoc

13
framework-docs/src/docs/asciidoc/web/webmvc.adoc

@ -2662,19 +2662,21 @@ query parameters and form fields. The following example shows how to do so: @@ -2662,19 +2662,21 @@ query parameters and form fields. The following example shows how to do so:
.Java
----
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
public String processSubmit(@ModelAttribute Pet pet) {
public String processSubmit(@ModelAttribute Pet pet) { // <1>
// method logic...
}
----
<1> Bind an instance of `Pet`.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
fun processSubmit(@ModelAttribute pet: Pet): String {
fun processSubmit(@ModelAttribute pet: Pet): String { // <1>
// method logic...
}
----
<1> Bind an instance of `Pet`.
The `Pet` instance above is sourced in one of the following ways:
@ -2702,18 +2704,21 @@ could load the `Account` from a data store: @@ -2702,18 +2704,21 @@ could load the `Account` from a data store:
.Java
----
@PutMapping("/accounts/{account}")
public String save(@ModelAttribute("account") Account account) {
public String save(@ModelAttribute("account") Account account) { // <1>
// ...
}
----
<1> Bind an instance of `Pet` using an explicit attribute name.
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@PutMapping("/accounts/{account}")
fun save(@ModelAttribute("account") account: Account): String {
fun save(@ModelAttribute("account") account: Account): String { // <1>
// ...
}
----
<1> Bind an instance of `Pet` using an explicit attribute name.
After the model attribute instance is obtained, data binding is applied. The
`WebDataBinder` class matches Servlet request parameter names (query parameters and form

Loading…
Cancel
Save