Skip to content

Commit

Permalink
Update docs on web controller method return values
Browse files Browse the repository at this point in the history
Closes gh-29349
  • Loading branch information
rstoyanchev committed Nov 11, 2022
1 parent d7d44c6 commit db9e89f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
7 changes: 3 additions & 4 deletions src/docs/asciidoc/web/webflux.adoc
Expand Up @@ -1985,10 +1985,9 @@ generally supported for all return values.
to be written (however, `text/event-stream` must be requested or declared in the mapping
through the `produces` attribute).

| Any other return value
| If a return value is not matched to any of the above, it is, by default, treated as a view
name, if it is `String` or `void` (default view name selection applies), or as a model
attribute to be added to the model, unless it is a simple type, as determined by
| Other return values
| If a return value remains unresolved in any other way, it is treated as a model
attribute, unless it is a simple type as determined by
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[BeanUtils#isSimpleProperty],
in which case it remains unresolved.
|===
Expand Down
29 changes: 12 additions & 17 deletions src/docs/asciidoc/web/webmvc.adoc
Expand Up @@ -2262,23 +2262,18 @@ supported for all return values.
| Write to the response `OutputStream` asynchronously. Also supported as the body of a
`ResponseEntity`. See <<mvc-ann-async>> and <<mvc-ann-async-http-streaming>>.

| Reactive types -- Reactor, RxJava, or others through `ReactiveAdapterRegistry`
| Alternative to `DeferredResult` with multi-value streams (for example, `Flux`, `Observable`)
collected to a `List`.

For streaming scenarios (for example, `text/event-stream`, `application/json+stream`),
`SseEmitter` and `ResponseBodyEmitter` are used instead, where `ServletOutputStream`
blocking I/O is performed on a Spring MVC-managed thread and back pressure is applied
against the completion of each write.

See <<mvc-ann-async>> and <<mvc-ann-async-reactive-types>>.

| Any other return value
| Any return value that does not match any of the earlier values in this table and that
is a `String` or `void` is treated as a view name (default view name selection through
`RequestToViewNameTranslator` applies), provided it is not a simple type, as determined by
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[BeanUtils#isSimpleProperty].
Values that are simple types remain unresolved.
| Reactor and other reactive types registered via `ReactiveAdapterRegistry`
| A single value type, e.g. `Mono`, is comparable to returning `DeferredResult`.
A multi-value type, e.g. `Flux`, may be treated as a stream depending on the requested
media type, e.g. "text/event-stream", "application/json+stream", or otherwise is
collected to a List and rendered as a single value. See <<mvc-ann-async>> and
<<mvc-ann-async-reactive-types>>.

| Other return values
| If a return value remains unresolved in any other way, it is treated as a model
attribute, unless it is a simple type as determined by
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[BeanUtils#isSimpleProperty],
in which case it remains unresolved.
|===


Expand Down

0 comments on commit db9e89f

Please sign in to comment.