|
|
|
|
@ -56,6 +56,7 @@ import org.springframework.boot.autoconfigure.web.format.WebConversionService;
@@ -56,6 +56,7 @@ import org.springframework.boot.autoconfigure.web.format.WebConversionService;
|
|
|
|
|
import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties.Format; |
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
|
import org.springframework.boot.convert.ApplicationConversionService; |
|
|
|
|
import org.springframework.boot.web.servlet.ServletRegistrationBean; |
|
|
|
|
import org.springframework.boot.web.servlet.filter.OrderedFormContentFilter; |
|
|
|
|
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter; |
|
|
|
|
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; |
|
|
|
|
@ -191,18 +192,22 @@ public class WebMvcAutoConfiguration {
@@ -191,18 +192,22 @@ public class WebMvcAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
private final ObjectProvider<DispatcherServletPath> dispatcherServletPath; |
|
|
|
|
|
|
|
|
|
private final ObjectProvider<ServletRegistrationBean<?>> servletRegistrations; |
|
|
|
|
|
|
|
|
|
final ResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer; |
|
|
|
|
|
|
|
|
|
public WebMvcAutoConfigurationAdapter(ResourceProperties resourceProperties, WebMvcProperties mvcProperties, |
|
|
|
|
ListableBeanFactory beanFactory, ObjectProvider<HttpMessageConverters> messageConvertersProvider, |
|
|
|
|
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider, |
|
|
|
|
ObjectProvider<DispatcherServletPath> dispatcherServletPath) { |
|
|
|
|
ObjectProvider<DispatcherServletPath> dispatcherServletPath, |
|
|
|
|
ObjectProvider<ServletRegistrationBean<?>> servletRegistrations) { |
|
|
|
|
this.resourceProperties = resourceProperties; |
|
|
|
|
this.mvcProperties = mvcProperties; |
|
|
|
|
this.beanFactory = beanFactory; |
|
|
|
|
this.messageConvertersProvider = messageConvertersProvider; |
|
|
|
|
this.resourceHandlerRegistrationCustomizer = resourceHandlerRegistrationCustomizerProvider.getIfAvailable(); |
|
|
|
|
this.dispatcherServletPath = dispatcherServletPath; |
|
|
|
|
this.servletRegistrations = servletRegistrations; |
|
|
|
|
this.mvcProperties.checkConfiguration(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -239,7 +244,7 @@ public class WebMvcAutoConfiguration {
@@ -239,7 +244,7 @@ public class WebMvcAutoConfiguration {
|
|
|
|
|
this.mvcProperties.getPathmatch().isUseRegisteredSuffixPattern()); |
|
|
|
|
this.dispatcherServletPath.ifAvailable((dispatcherPath) -> { |
|
|
|
|
String servletUrlMapping = dispatcherPath.getServletUrlMapping(); |
|
|
|
|
if (servletUrlMapping.equals("/")) { |
|
|
|
|
if (servletUrlMapping.equals("/") && singleDispatcherServlet()) { |
|
|
|
|
UrlPathHelper urlPathHelper = new UrlPathHelper(); |
|
|
|
|
urlPathHelper.setAlwaysUseFullPath(true); |
|
|
|
|
configurer.setUrlPathHelper(urlPathHelper); |
|
|
|
|
@ -247,6 +252,11 @@ public class WebMvcAutoConfiguration {
@@ -247,6 +252,11 @@ public class WebMvcAutoConfiguration {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean singleDispatcherServlet() { |
|
|
|
|
return this.servletRegistrations.stream().map(ServletRegistrationBean::getServlet) |
|
|
|
|
.filter(DispatcherServlet.class::isInstance).count() == 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@SuppressWarnings("deprecation") |
|
|
|
|
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { |
|
|
|
|
|