webflux.adoc (spring-framework-5.3.23) | : | webflux.adoc (spring-framework-5.3.24) | ||
---|---|---|---|---|
skipping to change at line 1473 | skipping to change at line 1473 | |||
.Kotlin | .Kotlin | |||
---- | ---- | |||
@GetMapping("/{name:[a-z-]+}-{version:\\d\\.\\d\\.\\d}{ext:\\.[a-z]+}") | @GetMapping("/{name:[a-z-]+}-{version:\\d\\.\\d\\.\\d}{ext:\\.[a-z]+}") | |||
fun handle(@PathVariable version: String, @PathVariable ext: String) { | fun handle(@PathVariable version: String, @PathVariable ext: String) { | |||
// ... | // ... | |||
} | } | |||
---- | ---- | |||
URI path patterns can also have embedded `${...}` placeholders that are resolved on startup | URI path patterns can also have embedded `${...}` placeholders that are resolved on startup | |||
through `PropertySourcesPlaceholderConfigurer` against local, system, environmen t, and | through `PropertySourcesPlaceholderConfigurer` against local, system, environmen t, and | |||
other property sources. You ca use this to, for example, parameterize a base URL based on | other property sources. You can use this to, for example, parameterize a base UR L based on | |||
some external configuration. | some external configuration. | |||
NOTE: Spring WebFlux uses `PathPattern` and the `PathPatternParser` for URI path matching support. | NOTE: Spring WebFlux uses `PathPattern` and the `PathPatternParser` for URI path matching support. | |||
Both classes are located in `spring-web` and are expressly designed for use with HTTP URL | Both classes are located in `spring-web` and are expressly designed for use with HTTP URL | |||
paths in web applications where a large number of URI path patterns are matched at runtime. | paths in web applications where a large number of URI path patterns are matched at runtime. | |||
Spring WebFlux does not support suffix pattern matching -- unlike Spring MVC, wh ere a | Spring WebFlux does not support suffix pattern matching -- unlike Spring MVC, wh ere a | |||
mapping such as `/person` also matches to `/person.{asterisk}`. For URL-based co ntent | mapping such as `/person` also matches to `/person.{asterisk}`. For URL-based co ntent | |||
negotiation, if needed, we recommend using a query parameter, which is simpler, more | negotiation, if needed, we recommend using a query parameter, which is simpler, more | |||
explicit, and less vulnerable to URL path based exploits. | explicit, and less vulnerable to URL path based exploits. | |||
skipping to change at line 1905 | skipping to change at line 1905 | |||
// TODO: See <<webflux-caching-etag-lastmodified>> for details. | // TODO: See <<webflux-caching-etag-lastmodified>> for details. | |||
If none of the above is true, a `void` return type can also indicate "`no resp onse body`" for | If none of the above is true, a `void` return type can also indicate "`no resp onse body`" for | |||
REST controllers or default view name selection for HTML controllers. | REST controllers or default view name selection for HTML controllers. | |||
| `Flux<ServerSentEvent>`, `Observable<ServerSentEvent>`, or other reactive type | | `Flux<ServerSentEvent>`, `Observable<ServerSentEvent>`, or other reactive type | |||
| Emit server-sent events. The `ServerSentEvent` wrapper can be omitted when onl y data needs | | Emit server-sent events. The `ServerSentEvent` wrapper can be omitted when onl y data needs | |||
to be written (however, `text/event-stream` must be requested or declared in t he mapping | to be written (however, `text/event-stream` must be requested or declared in t he mapping | |||
through the `produces` attribute). | through the `produces` attribute). | |||
| Any other return value | | Other return values | |||
| If a return value is not matched to any of the above, it is, by default, treat | | If a return value remains unresolved in any other way, it is treated as a mode | |||
ed as a view | l | |||
name, if it is `String` or `void` (default view name selection applies), or as | attribute, unless it is a simple type as determined by | |||
a model | ||||
attribute to be added to the model, unless it is a simple type, as determined | ||||
by | ||||
{api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[ BeanUtils#isSimpleProperty], | {api-spring-framework}/beans/BeanUtils.html#isSimpleProperty-java.lang.Class-[ BeanUtils#isSimpleProperty], | |||
in which case it remains unresolved. | in which case it remains unresolved. | |||
|=== | |=== | |||
[[webflux-ann-typeconversion]] | [[webflux-ann-typeconversion]] | |||
==== Type Conversion | ==== Type Conversion | |||
[.small]#<<web.adoc#mvc-ann-typeconversion, Web MVC>># | [.small]#<<web.adoc#mvc-ann-typeconversion, Web MVC>># | |||
Some annotated controller method arguments that represent String-based request i nput (for example, | Some annotated controller method arguments that represent String-based request i nput (for example, | |||
`@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@Coo kieValue`) | `@RequestParam`, `@RequestHeader`, `@PathVariable`, `@MatrixVariable`, and `@Coo kieValue`) | |||
skipping to change at line 4108 | skipping to change at line 4107 | |||
Unlike Spring MVC, at present, in WebFlux, there is no way to transparently rewr ite static | Unlike Spring MVC, at present, in WebFlux, there is no way to transparently rewr ite static | |||
resource URLs, since there are no view technologies that can make use of a non-b locking chain | resource URLs, since there are no view technologies that can make use of a non-b locking chain | |||
of resolvers and transformers. When serving only local resources, the workaround is to use | of resolvers and transformers. When serving only local resources, the workaround is to use | |||
`ResourceUrlProvider` directly (for example, through a custom element) and block . | `ResourceUrlProvider` directly (for example, through a custom element) and block . | |||
Note that, when using both `EncodedResourceResolver` (for example, Gzip, Brotli encoded) and | Note that, when using both `EncodedResourceResolver` (for example, Gzip, Brotli encoded) and | |||
`VersionedResourceResolver`, they must be registered in that order, to ensure co ntent-based | `VersionedResourceResolver`, they must be registered in that order, to ensure co ntent-based | |||
versions are always computed reliably based on the unencoded file. | versions are always computed reliably based on the unencoded 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. | |||
[[webflux-config-path-matching]] | [[webflux-config-path-matching]] | |||
=== Path Matching | === Path Matching | |||
[.small]#<<web.adoc#mvc-config-path-matching, Web MVC>># | [.small]#<<web.adoc#mvc-config-path-matching, Web MVC>># | |||
You can customize options related to path matching. For details on the individua l options, see the | You can customize options related to path matching. For details on the individua l options, see the | |||
{api-spring-framework}/web/reactive/config/PathMatchConfigurer.html[`PathMatchCo nfigurer`] javadoc. | {api-spring-framework}/web/reactive/config/PathMatchConfigurer.html[`PathMatchCo nfigurer`] javadoc. | |||
End of changes. 4 change blocks. | ||||
15 lines changed or deleted | 22 lines changed or added |