Fix migration to asciidoctor tabs
The automation to asciidoctor tabs did not migrate properly for all cases this commit fixes the migration. See gh-30435
This commit is contained in:
@@ -24,11 +24,11 @@ Java::
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Declaring an `@ExceptionHandler`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
class SimpleController {
|
||||
@@ -42,6 +42,8 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Declaring an `@ExceptionHandler`.
|
||||
======
|
||||
|
||||
|
||||
|
||||
The exception can match against a top-level exception being propagated (that is, a direct
|
||||
|
||||
@@ -41,11 +41,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using the `@InitBinder` annotation.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
class FormController {
|
||||
@@ -61,6 +61,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using the `@InitBinder` annotation.
|
||||
======
|
||||
--
|
||||
|
||||
Alternatively, when using a `Formatter`-based setup through a shared
|
||||
@@ -85,11 +86,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Adding a custom formatter (a `DateFormatter`, in this case).
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
class FormController {
|
||||
@@ -103,6 +104,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Adding a custom formatter (a `DateFormatter`, in this case).
|
||||
======
|
||||
--
|
||||
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ Java::
|
||||
//...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Get the cookie value.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/demo")
|
||||
fun handle(@CookieValue("JSESSIONID") cookie: String) { // <1>
|
||||
@@ -38,6 +38,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Get the cookie value.
|
||||
======
|
||||
|
||||
|
||||
Type conversion is applied automatically if the target method parameter type is not
|
||||
|
||||
@@ -18,16 +18,17 @@ Java::
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
|
||||
public String processSubmit(@ModelAttribute Pet pet) { } // <1>
|
||||
----
|
||||
======
|
||||
<1> Bind an instance of `Pet`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
|
||||
fun processSubmit(@ModelAttribute pet: Pet): String { } // <1>
|
||||
----
|
||||
<1> Bind an instance of `Pet`.
|
||||
======
|
||||
|
||||
The `Pet` instance in the preceding example is resolved as follows:
|
||||
|
||||
@@ -63,11 +64,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Adding a `BindingResult`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
|
||||
fun processSubmit(@ModelAttribute("pet") pet: Pet, result: BindingResult): String { // <1>
|
||||
@@ -78,6 +79,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Adding a `BindingResult`.
|
||||
======
|
||||
|
||||
You can automatically apply validation after data binding by adding the
|
||||
`jakarta.validation.Valid` annotation or Spring's `@Validated` annotation (see also
|
||||
@@ -98,11 +100,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@Valid` on a model attribute argument.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/owners/{ownerId}/pets/{petId}/edit")
|
||||
fun processSubmit(@Valid @ModelAttribute("pet") pet: Pet, result: BindingResult): String { // <1>
|
||||
@@ -113,6 +115,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@Valid` on a model attribute argument.
|
||||
======
|
||||
|
||||
Spring WebFlux, unlike Spring MVC, supports reactive types in the model -- for example,
|
||||
`Mono<Account>` or `io.reactivex.Single<Account>`. You can declare a `@ModelAttribute` argument
|
||||
|
||||
@@ -95,12 +95,12 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestPart` to get the metadata.
|
||||
<2> Using `@RequestPart` to get the file.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/")
|
||||
fun handle(@RequestPart("meta-data") Part metadata, // <1>
|
||||
@@ -110,6 +110,7 @@ Java::
|
||||
----
|
||||
<1> Using `@RequestPart` to get the metadata.
|
||||
<2> Using `@RequestPart` to get the file.
|
||||
======
|
||||
--
|
||||
|
||||
|
||||
@@ -128,11 +129,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestPart` to get the metadata.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/")
|
||||
fun handle(@RequestPart("meta-data") metadata: MetaData): String { // <1>
|
||||
@@ -140,6 +141,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@RequestPart` to get the metadata.
|
||||
======
|
||||
--
|
||||
|
||||
You can use `@RequestPart` in combination with `jakarta.validation.Valid` or Spring's
|
||||
@@ -189,11 +191,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestBody`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/")
|
||||
fun handle(@RequestBody parts: MultiValueMap<String, Part>): String { // <1>
|
||||
@@ -201,6 +203,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@RequestBody`.
|
||||
======
|
||||
--
|
||||
|
||||
[[partevent]]
|
||||
@@ -250,7 +253,6 @@ Java::
|
||||
}));
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestBody`.
|
||||
<2> The final `PartEvent` for a particular part will have `isLast()` set to `true`, and can be
|
||||
followed by additional events belonging to subsequent parts.
|
||||
@@ -262,8 +264,9 @@ file upload.
|
||||
<5> Handling the file upload.
|
||||
<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@PostMapping("/")
|
||||
fun handle(@RequestBody allPartsEvents: Flux<PartEvent>) = { // <1>
|
||||
@@ -299,6 +302,7 @@ file upload.
|
||||
<4> Handling the form field.
|
||||
<5> Handling the file upload.
|
||||
<6> The body contents must be completely consumed, relayed, or released to avoid memory leaks.
|
||||
======
|
||||
|
||||
Received part events can also be relayed to another service by using the `WebClient`.
|
||||
See xref:web/webflux-webclient/client-body.adoc#webflux-client-body-multipart[Multipart Data].
|
||||
|
||||
@@ -18,11 +18,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestAttribute`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/")
|
||||
fun handle(@RequestAttribute client: Client): String { // <1>
|
||||
@@ -30,5 +30,6 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@RequestAttribute`.
|
||||
======
|
||||
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ Java::
|
||||
//...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Get the value of the `Accept-Encoding` header.
|
||||
<2> Get the value of the `Keep-Alive` header.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/demo")
|
||||
fun handle(
|
||||
@@ -50,6 +50,7 @@ Java::
|
||||
----
|
||||
<1> Get the value of the `Accept-Encoding` header.
|
||||
<2> Get the value of the `Keep-Alive` header.
|
||||
======
|
||||
|
||||
Type conversion is applied automatically if the target method parameter type is not
|
||||
`String`. See xref:web/webflux/controller/ann-methods/typeconversion.adoc[Type Conversion].
|
||||
|
||||
@@ -28,11 +28,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@RequestParam`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
import org.springframework.ui.set
|
||||
|
||||
@@ -53,6 +53,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@RequestParam`.
|
||||
======
|
||||
|
||||
TIP: The Servlet API "`request parameter`" concept conflates query parameters, form
|
||||
data, and multiparts into one. However, in WebFlux, each is accessed individually through
|
||||
|
||||
@@ -18,11 +18,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using `@SessionAttribute`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/")
|
||||
fun handle(@SessionAttribute user: User): String { // <1>
|
||||
@@ -30,6 +30,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using `@SessionAttribute`.
|
||||
======
|
||||
|
||||
For use cases that require adding or removing session attributes, consider injecting
|
||||
`WebSession` into the controller method.
|
||||
|
||||
@@ -23,11 +23,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using the `@SessionAttributes` annotation.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
@SessionAttributes("pet") // <1>
|
||||
@@ -36,6 +36,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Using the `@SessionAttributes` annotation.
|
||||
======
|
||||
|
||||
On the first request, when a model attribute with the name, `pet`, is added to the model,
|
||||
it is automatically promoted to and saved in the `WebSession`. It remains there until
|
||||
@@ -65,12 +66,12 @@ Java::
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Using the `@SessionAttributes` annotation.
|
||||
<2> Using a `SessionStatus` variable.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
@SessionAttributes("pet") // <1>
|
||||
@@ -90,5 +91,6 @@ Java::
|
||||
----
|
||||
<1> Using the `@SessionAttributes` annotation.
|
||||
<2> Using a `SessionStatus` variable.
|
||||
======
|
||||
|
||||
|
||||
|
||||
@@ -155,12 +155,12 @@ Java::
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Class-level URI mapping.
|
||||
<2> Method-level URI mapping.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Controller
|
||||
@RequestMapping("/owners/{ownerId}") // <1>
|
||||
@@ -174,6 +174,7 @@ Java::
|
||||
----
|
||||
<1> Class-level URI mapping.
|
||||
<2> Method-level URI mapping.
|
||||
======
|
||||
--
|
||||
|
||||
|
||||
@@ -352,11 +353,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Check that `myParam` equals `myValue`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/pets/{petId}", params = ["myParam=myValue"]) // <1>
|
||||
fun findPet(@PathVariable petId: String) {
|
||||
@@ -364,6 +365,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Check that `myParam` equals `myValue`.
|
||||
======
|
||||
|
||||
You can also use the same with request header conditions, as the following example shows:
|
||||
|
||||
@@ -378,11 +380,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Check that `myHeader` equals `myValue`.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@GetMapping("/pets/{petId}", headers = ["myHeader=myValue"]) // <1>
|
||||
fun findPet(@PathVariable petId: String) {
|
||||
@@ -390,6 +392,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Check that `myHeader` equals `myValue`.
|
||||
======
|
||||
|
||||
|
||||
|
||||
@@ -466,14 +469,14 @@ Java::
|
||||
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Inject target handlers and the handler mapping for controllers.
|
||||
<2> Prepare the request mapping metadata.
|
||||
<3> Get the handler method.
|
||||
<4> Add the registration.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Configuration
|
||||
class MyConfig {
|
||||
@@ -493,6 +496,7 @@ Java::
|
||||
<2> Prepare the request mapping metadata.
|
||||
<3> Get the handler method.
|
||||
<4> Add the registration.
|
||||
======
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ Java::
|
||||
// ...
|
||||
}
|
||||
----
|
||||
======
|
||||
<1> Scan the `org.example.web` package.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
.Kotlin
|
||||
----
|
||||
@Configuration
|
||||
@ComponentScan("org.example.web") // <1>
|
||||
@@ -39,6 +39,7 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Scan the `org.example.web` package.
|
||||
======
|
||||
|
||||
`@RestController` is a xref:core/beans/classpath-scanning.adoc#beans-meta-annotations[composed annotation] that is
|
||||
itself meta-annotated with `@Controller` and `@ResponseBody`, indicating a controller whose
|
||||
|
||||
Reference in New Issue
Block a user