webmvc.adoc (spring-framework-5.3.23) | : | webmvc.adoc (spring-framework-5.3.24) | ||
---|---|---|---|---|
skipping to change at line 2181 | skipping to change at line 2181 | |||
| `ResponseBodyEmitter`, `SseEmitter` | | `ResponseBodyEmitter`, `SseEmitter` | |||
| Emit a stream of objects asynchronously to be written to the response with | | Emit a stream of objects asynchronously to be written to the response with | |||
`HttpMessageConverter` implementations. Also supported as the body of a `Respo nseEntity`. | `HttpMessageConverter` implementations. Also supported as the body of a `Respo nseEntity`. | |||
See <<mvc-ann-async>> and <<mvc-ann-async-http-streaming>>. | See <<mvc-ann-async>> and <<mvc-ann-async-http-streaming>>. | |||
| `StreamingResponseBody` | | `StreamingResponseBody` | |||
| Write to the response `OutputStream` asynchronously. Also supported as the bod y of a | | Write to the response `OutputStream` asynchronously. Also supported as the bod y of a | |||
`ResponseEntity`. See <<mvc-ann-async>> and <<mvc-ann-async-http-streaming>>. | `ResponseEntity`. See <<mvc-ann-async>> and <<mvc-ann-async-http-streaming>>. | |||
| Reactive types -- Reactor, RxJava, or others through `ReactiveAdapterRegistry` | | Reactor and other reactive types registered via `ReactiveAdapterRegistry` | |||
| Alternative to `DeferredResult` with multi-value streams (for example, `Flux`, | | A single value type, e.g. `Mono`, is comparable to returning `DeferredResult`. | |||
`Observable`) | A multi-value type, e.g. `Flux`, may be treated as a stream depending on the r | |||
collected to a `List`. | equested | |||
media type, e.g. "text/event-stream", "application/json+stream", or otherwise | ||||
For streaming scenarios (for example, `text/event-stream`, `application/json+s | is | |||
tream`), | collected to a List and rendered as a single value. See <<mvc-ann-async>> and | |||
`SseEmitter` and `ResponseBodyEmitter` are used instead, where `ServletOutputS | <<mvc-ann-async-reactive-types>>. | |||
tream` | ||||
blocking I/O is performed on a Spring MVC-managed thread and back pressure is | | Other return values | |||
applied | | If a return value remains unresolved in any other way, it is treated as a mode | |||
against the completion of each write. | l | |||
attribute, unless it is a simple type as determined by | ||||
See <<mvc-ann-async>> and <<mvc-ann-async-reactive-types>>. | {api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[ | |||
BeanUtils#isSimpleProperty], | ||||
| Any other return value | in which case it remains unresolved. | |||
| Any return value that does not match any of the earlier values in this table a | ||||
nd 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 d | ||||
etermined by | ||||
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[ | ||||
BeanUtils#isSimpleProperty]. | ||||
Values that are simple types remain unresolved. | ||||
|=== | |=== | |||
[[mvc-ann-typeconversion]] | [[mvc-ann-typeconversion]] | |||
==== Type Conversion | ==== Type Conversion | |||
[.small]#<<web-reactive.adoc#webflux-ann-typeconversion, WebFlux>># | [.small]#<<web-reactive.adoc#webflux-ann-typeconversion, WebFlux>># | |||
Some annotated controller method arguments that represent `String`-based request input (such as | Some annotated controller method arguments that represent `String`-based request input (such as | |||
`@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@Coo kieValue`) | `@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@Coo kieValue`) | |||
can require type conversion if the argument is declared as something other than `String`. | can require type conversion if the argument is declared as something other than `String`. | |||
skipping to change at line 5682 | skipping to change at line 5677 | |||
You can then use `ResourceUrlProvider` to rewrite URLs and apply the full chain of resolvers and | You can then use `ResourceUrlProvider` to rewrite URLs and apply the full chain of resolvers and | |||
transformers -- for example, to insert versions. The MVC configuration provides a `ResourceUrlProvider` | transformers -- for example, to insert versions. The MVC configuration provides a `ResourceUrlProvider` | |||
bean so that it can be injected into others. You can also make the rewrite trans parent with the | bean so that it can be injected into others. You can also make the rewrite trans parent with the | |||
`ResourceUrlEncodingFilter` for Thymeleaf, JSPs, FreeMarker, and others with URL tags that | `ResourceUrlEncodingFilter` for Thymeleaf, JSPs, FreeMarker, and others with URL tags that | |||
rely on `HttpServletResponse#encodeURL`. | rely on `HttpServletResponse#encodeURL`. | |||
Note that, when using both `EncodedResourceResolver` (for example, for serving g zipped or | Note that, when using both `EncodedResourceResolver` (for example, for serving g zipped or | |||
brotli-encoded resources) and `VersionResourceResolver`, you must register them in this order. | brotli-encoded resources) and `VersionResourceResolver`, you must register them in this order. | |||
That ensures content-based versions are always computed reliably, based on the u nencoded file. | That ensures content-based versions are always computed reliably, based on the u nencoded file. | |||
https://www.webjars.org/documentation[WebJars] are also supported through the | For https://www.webjars.org/documentation[WebJars], versioned URLs like | |||
`/webjars/jquery/1.2.0/jquery.min.js` are the recommended and most efficient way | ||||
to use them. | ||||
The related resource location is configured out of the box with Spring Boot (or | ||||
can be configured | ||||
manually via `ResourceHandlerRegistry`) and does not require to add the | ||||
`org.webjars:webjars-locator-core` dependency. | ||||
Version-less URLs like `/webjars/jquery/jquery.min.js` are supported through the | ||||
`WebJarsResourceResolver` which is automatically registered when the | `WebJarsResourceResolver` which is automatically registered when the | |||
`org.webjars:webjars-locator-core` library is present on the classpath. The reso | `org.webjars:webjars-locator-core` library is present on the classpath, at the c | |||
lver can | ost of a | |||
re-write URLs to include the version of the jar and can also match against incom | classpath scanning that could slow down application startup. The resolver can re | |||
ing URLs | -write URLs to | |||
without versions -- for example, from `/jquery/jquery.min.js` to | include the version of the jar and can also match against incoming URLs without | |||
`/jquery/1.2.0/jquery.min.js`. | versions | |||
-- for example, from `/webjars/jquery/jquery.min.js` to `/webjars/jquery/1.2.0/j | ||||
query.min.js`. | ||||
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options | TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options | |||
for fine-grained control, e.g. last-modified behavior and optimized resource res olution. | for fine-grained control, e.g. last-modified behavior and optimized resource res olution. | |||
[[mvc-default-servlet-handler]] | [[mvc-default-servlet-handler]] | |||
=== Default Servlet | === Default Servlet | |||
Spring MVC allows for mapping the `DispatcherServlet` to `/` (thus overriding th e mapping | Spring MVC allows for mapping the `DispatcherServlet` to `/` (thus overriding th e mapping | |||
of the container's default Servlet), while still allowing static resource reques ts to be | of the container's default Servlet), while still allowing static resource reques ts to be | |||
handled by the container's default Servlet. It configures a | handled by the container's default Servlet. It configures a | |||
End of changes. 3 change blocks. | ||||
32 lines changed or deleted | 33 lines changed or added |