@ -42,6 +42,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ResourceLoaderAware ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
import org.springframework.context.annotation.Import ;
import org.springframework.core.Ordered ;
import org.springframework.core.annotation.Order ;
import org.springframework.core.convert.converter.Converter ;
@ -63,6 +64,7 @@ import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver ;
import org.springframework.web.servlet.View ;
import org.springframework.web.servlet.ViewResolver ;
import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration ;
import org.springframework.web.servlet.config.annotation.EnableWebMvc ;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry ;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry ;
@ -70,6 +72,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupp
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter ;
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping ;
import org.springframework.web.servlet.i18n.FixedLocaleResolver ;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter ;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler ;
import org.springframework.web.servlet.view.BeanNameViewResolver ;
import org.springframework.web.servlet.view.ContentNegotiatingViewResolver ;
@ -128,7 +131,7 @@ public class WebMvcAutoConfiguration {
// Defined as a nested config to ensure WebMvcConfigurerAdapter is not read when not
// on the classpath
@Configuration
@ EnableWebMvc
@ Import( EnableWebMvcConfiguration. class )
@EnableConfigurationProperties ( { WebMvcProperties . class , ResourceProperties . class } )
public static class WebMvcAutoConfigurationAdapter extends WebMvcConfigurerAdapter {
@ -322,4 +325,24 @@ public class WebMvcAutoConfiguration {
}
/ * *
* Configuration equivalent to { @code @EnableWebMvc } but with extra
* { @link WebMvcProperties } support .
* /
@Configuration
public static class EnableWebMvcConfiguration extends DelegatingWebMvcConfiguration {
@Autowired ( required = false )
private WebMvcProperties mvcProperties ;
@Bean
@Override
public RequestMappingHandlerAdapter requestMappingHandlerAdapter ( ) {
RequestMappingHandlerAdapter adapter = super . requestMappingHandlerAdapter ( ) ;
adapter . setIgnoreDefaultModelOnRedirect ( this . mvcProperties = = null ? true
: this . mvcProperties . isIgnoreDefaultModelOnRedirect ( ) ) ;
return adapter ;
}
}
}