Merge branch '3.1.x'

Closes gh-36794
pull/36455/head
Andy Wilkinson 1 year ago
commit d658a8cd47

@ -46,6 +46,28 @@ If you want to take complete control of Spring WebFlux, you can add your own `@C
[[web.reactive.webflux.conversion-service]]
==== Spring WebFlux Conversion Service
If you want to customize the `ConversionService` used by Spring WebFlux, you can provide a `WebFluxConfigurer` bean with an `addFormatters` method.
Conversion can also be customized using the `spring.webflux.format.*` configuration properties.
When not configured, the following defaults are used:
|===
|Property |`DateTimeFormatter`
|configprop:spring.webflux.format.date[]
|`ofLocalizedDate(FormatStyle.SHORT)`
|configprop:spring.webflux.format.time[]
|`ofLocalizedTime(FormatStyle.SHORT)`
|configprop:spring.webflux.format.date-time[]
|`ofLocalizedDateTime(FormatStyle.SHORT)`
|===
[[web.reactive.webflux.httpcodecs]] [[web.reactive.webflux.httpcodecs]]
==== HTTP Codecs with HttpMessageReaders and HttpMessageWriters ==== HTTP Codecs with HttpMessageReaders and HttpMessageWriters
Spring WebFlux uses the `HttpMessageReader` and `HttpMessageWriter` interfaces to convert HTTP requests and responses. Spring WebFlux uses the `HttpMessageReader` and `HttpMessageWriter` interfaces to convert HTTP requests and responses.

@ -48,14 +48,31 @@ If you want to provide custom instances of `RequestMappingHandlerMapping`, `Requ
If you want to take complete control of Spring MVC, you can add your own `@Configuration` annotated with `@EnableWebMvc`, or alternatively add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`. If you want to take complete control of Spring MVC, you can add your own `@Configuration` annotated with `@EnableWebMvc`, or alternatively add your own `@Configuration`-annotated `DelegatingWebMvcConfiguration` as described in the Javadoc of `@EnableWebMvc`.
[NOTE]
====
[[web.servlet.spring-mvc.conversion-service]]
==== Spring MVC Conversion Service
Spring MVC uses a different `ConversionService` to the one used to convert values from your `application.properties` or `application.yaml` file. Spring MVC uses a different `ConversionService` to the one used to convert values from your `application.properties` or `application.yaml` file.
It means that `Period`, `Duration` and `DataSize` converters are not available and that `@DurationUnit` and `@DataSizeUnit` annotations will be ignored. It means that `Period`, `Duration` and `DataSize` converters are not available and that `@DurationUnit` and `@DataSizeUnit` annotations will be ignored.
If you want to customize the `ConversionService` used by Spring MVC, you can provide a `WebMvcConfigurer` bean with an `addFormatters` method. If you want to customize the `ConversionService` used by Spring MVC, you can provide a `WebMvcConfigurer` bean with an `addFormatters` method.
From this method you can register any converter that you like, or you can delegate to the static methods available on `ApplicationConversionService`. From this method you can register any converter that you like, or you can delegate to the static methods available on `ApplicationConversionService`.
====
Conversion can also be customized using the `spring.mvc.format.*` configuration properties.
When not configured, the following defaults are used:
|===
|Property |`DateTimeFormatter`
|configprop:spring.mvc.format.date[]
|`ofLocalizedDate(FormatStyle.SHORT)`
|configprop:spring.mvc.format.time[]
|`ofLocalizedTime(FormatStyle.SHORT)`
|configprop:spring.mvc.format.date-time[]
|`ofLocalizedDateTime(FormatStyle.SHORT)`
|===

Loading…
Cancel
Save