|
|
|
@ -213,6 +213,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
this.applicationContext = applicationContext; |
|
|
|
this.applicationContext = applicationContext; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the associated Spring {@link ApplicationContext}. |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
public ApplicationContext getApplicationContext() { |
|
|
|
public ApplicationContext getApplicationContext() { |
|
|
|
return this.applicationContext; |
|
|
|
return this.applicationContext; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -226,6 +230,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
this.servletContext = servletContext; |
|
|
|
this.servletContext = servletContext; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return the associated {@link javax.servlet.ServletContext}. |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
|
|
|
|
*/ |
|
|
|
public ServletContext getServletContext() { |
|
|
|
public ServletContext getServletContext() { |
|
|
|
return this.servletContext; |
|
|
|
return this.servletContext; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -268,6 +276,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Protected method for plugging in a custom subclass of |
|
|
|
* Protected method for plugging in a custom subclass of |
|
|
|
* {@link RequestMappingHandlerMapping}. |
|
|
|
* {@link RequestMappingHandlerMapping}. |
|
|
|
|
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { |
|
|
|
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { |
|
|
|
return new RequestMappingHandlerMapping(); |
|
|
|
return new RequestMappingHandlerMapping(); |
|
|
|
@ -318,6 +327,32 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
public void configurePathMatch(PathMatchConfigurer configurer) { |
|
|
|
public void configurePathMatch(PathMatchConfigurer configurer) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a global {@link PathMatcher} instance for path matching |
|
|
|
|
|
|
|
* patterns in {@link HandlerMapping}s. |
|
|
|
|
|
|
|
* This instance can be configured using the {@link PathMatchConfigurer} |
|
|
|
|
|
|
|
* in {@link #configurePathMatch(PathMatchConfigurer)}. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
public PathMatcher mvcPathMatcher() { |
|
|
|
|
|
|
|
PathMatcher pathMatcher = getPathMatchConfigurer().getPathMatcher(); |
|
|
|
|
|
|
|
return (pathMatcher != null ? pathMatcher : new AntPathMatcher()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a global {@link UrlPathHelper} instance for path matching |
|
|
|
|
|
|
|
* patterns in {@link HandlerMapping}s. |
|
|
|
|
|
|
|
* This instance can be configured using the {@link PathMatchConfigurer} |
|
|
|
|
|
|
|
* in {@link #configurePathMatch(PathMatchConfigurer)}. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
public UrlPathHelper mvcUrlPathHelper() { |
|
|
|
|
|
|
|
UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper(); |
|
|
|
|
|
|
|
return (pathHelper != null ? pathHelper : new UrlPathHelper()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return a {@link ContentNegotiationManager} instance to use to determine |
|
|
|
* Return a {@link ContentNegotiationManager} instance to use to determine |
|
|
|
* requested {@linkplain MediaType media types} in a given request. |
|
|
|
* requested {@linkplain MediaType media types} in a given request. |
|
|
|
@ -414,8 +449,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
if (handlerMapping != null) { |
|
|
|
if (handlerMapping != null) { |
|
|
|
handlerMapping.setPathMatcher(mvcPathMatcher()); |
|
|
|
handlerMapping.setPathMatcher(mvcPathMatcher()); |
|
|
|
handlerMapping.setUrlPathHelper(mvcUrlPathHelper()); |
|
|
|
handlerMapping.setUrlPathHelper(mvcUrlPathHelper()); |
|
|
|
handlerMapping.setInterceptors(new HandlerInterceptor[] { |
|
|
|
handlerMapping.setInterceptors(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider())); |
|
|
|
new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider())}); |
|
|
|
|
|
|
|
handlerMapping.setCorsConfigurations(getCorsConfigurations()); |
|
|
|
handlerMapping.setCorsConfigurations(getCorsConfigurations()); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
@ -431,6 +465,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
|
|
|
protected void addResourceHandlers(ResourceHandlerRegistry registry) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A {@link ResourceUrlProvider} bean for use with the MVC dispatcher. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public ResourceUrlProvider mvcResourceUrlProvider() { |
|
|
|
public ResourceUrlProvider mvcResourceUrlProvider() { |
|
|
|
ResourceUrlProvider urlProvider = new ResourceUrlProvider(); |
|
|
|
ResourceUrlProvider urlProvider = new ResourceUrlProvider(); |
|
|
|
@ -596,36 +634,6 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a global {@link PathMatcher} instance for path matching |
|
|
|
|
|
|
|
* patterns in {@link HandlerMapping}s. |
|
|
|
|
|
|
|
* This instance can be configured using the {@link PathMatchConfigurer} |
|
|
|
|
|
|
|
* in {@link #configurePathMatch(PathMatchConfigurer)}. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
public PathMatcher mvcPathMatcher() { |
|
|
|
|
|
|
|
if (getPathMatchConfigurer().getPathMatcher() != null) { |
|
|
|
|
|
|
|
return getPathMatchConfigurer().getPathMatcher(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return new AntPathMatcher(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return a global {@link UrlPathHelper} instance for path matching |
|
|
|
|
|
|
|
* patterns in {@link HandlerMapping}s. |
|
|
|
|
|
|
|
* This instance can be configured using the {@link PathMatchConfigurer} |
|
|
|
|
|
|
|
* in {@link #configurePathMatch(PathMatchConfigurer)}. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
public UrlPathHelper mvcUrlPathHelper() { |
|
|
|
|
|
|
|
UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper(); |
|
|
|
|
|
|
|
return (pathHelper != null ? pathHelper : new UrlPathHelper()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to |
|
|
|
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to |
|
|
|
* the ones registered by default. |
|
|
|
* the ones registered by default. |
|
|
|
@ -739,6 +747,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return an instance of {@link CompositeUriComponentsContributor} for use with |
|
|
|
* Return an instance of {@link CompositeUriComponentsContributor} for use with |
|
|
|
* {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}. |
|
|
|
* {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}. |
|
|
|
|
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
public CompositeUriComponentsContributor mvcUriComponentsContributor() { |
|
|
|
public CompositeUriComponentsContributor mvcUriComponentsContributor() { |
|
|
|
|