Detect ConfigurableWebBindingInitializer bean and register with MVC

Previously, to use a custom ConfigurableWebBindingInitializer, it was
necessary to extend WebMvcConfigurationSupport and override
getConfigurableWebBindingInitializer. This had the unwanted
side-effect of switching off the auto-configuration of Spring MVC.

This commit updates the auto-configuration to look for a
ConfigurableWebBindingInitializer bean and register it with Spring
MVC.

Closes gh-2526
This commit is contained in:
Andy Wilkinson
2015-08-13 15:10:40 +01:00
parent 511c6d39fa
commit 51dd806a98
3 changed files with 48 additions and 0 deletions

View File

@@ -1216,6 +1216,7 @@ The auto-configuration adds the following features on top of Spring's defaults:
* Automatic registration of `MessageCodesResolver` (see below).
* Static `index.html` support.
* Custom `Favicon` support.
* Automatic use of a `ConfigurableWebBindingInitializer` bean (see below).
If you want to take complete control of Spring MVC, you can add your own `@Configuration`
annotated with `@EnableWebMvc`. If you want to keep Spring Boot MVC features, and
@@ -1345,6 +1346,13 @@ https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resou
and in Spring Framework's {spring-reference}/#mvc-config-static-resources[reference documentation].
====
[[boot-features-spring-mvc-web-binding-initializer]]
==== ConfigurableWebBindingInitializer
Spring MVC uses a `WebBindingInitializer` to initialize a `WebDataBinder` for a particular
request. If you create your own `ConfigurableWebBindingInitializer` `@Bean`, Spring Boot
will automatically configure Spring MVC to use it.
[[boot-features-spring-mvc-template-engines]]