|
|
|
@ -217,6 +217,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; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -230,6 +234,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; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -270,8 +278,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Protected method for plugging in a custom sub-class 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(); |
|
|
|
@ -322,6 +331,32 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
protected void configurePathMatch(PathMatchConfigurer configurer) { |
|
|
|
protected 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. |
|
|
|
@ -419,8 +454,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 { |
|
|
|
@ -436,6 +470,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(); |
|
|
|
@ -512,8 +550,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Protected method for plugging in a custom sub-class of |
|
|
|
* Protected method for plugging in a custom subclass of |
|
|
|
* {@link RequestMappingHandlerAdapter}. |
|
|
|
* {@link RequestMappingHandlerAdapter}. |
|
|
|
|
|
|
|
* @since 4.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { |
|
|
|
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { |
|
|
|
return new RequestMappingHandlerAdapter(); |
|
|
|
return new RequestMappingHandlerAdapter(); |
|
|
|
@ -603,41 +642,12 @@ 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()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Provide access to the shared custom argument resolvers used by the |
|
|
|
* Provide access to the shared custom argument resolvers used by the |
|
|
|
* {@link RequestMappingHandlerAdapter} and the |
|
|
|
* {@link RequestMappingHandlerAdapter} and the |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. This method cannot be |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. This method cannot be |
|
|
|
* overridden, use {@link #addArgumentResolvers(List)} instead. |
|
|
|
* overridden, use {@link #addArgumentResolvers(List)} instead. |
|
|
|
|
|
|
|
* @since 4.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() { |
|
|
|
protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() { |
|
|
|
if (this.argumentResolvers == null) { |
|
|
|
if (this.argumentResolvers == null) { |
|
|
|
@ -666,6 +676,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
* {@link RequestMappingHandlerAdapter} and the |
|
|
|
* {@link RequestMappingHandlerAdapter} and the |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. This method cannot be |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. This method cannot be |
|
|
|
* overridden, use {@link #addReturnValueHandlers(List)} instead. |
|
|
|
* overridden, use {@link #addReturnValueHandlers(List)} instead. |
|
|
|
|
|
|
|
* @since 4.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() { |
|
|
|
protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() { |
|
|
|
if (this.returnValueHandlers == null) { |
|
|
|
if (this.returnValueHandlers == null) { |
|
|
|
@ -774,6 +785,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() { |
|
|
|
@ -880,8 +892,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Protected method for plugging in a custom sub-class of |
|
|
|
* Protected method for plugging in a custom subclass of |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. |
|
|
|
* {@link ExceptionHandlerExceptionResolver}. |
|
|
|
|
|
|
|
* @since 4.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected ExceptionHandlerExceptionResolver createExceptionHandlerExceptionResolver() { |
|
|
|
protected ExceptionHandlerExceptionResolver createExceptionHandlerExceptionResolver() { |
|
|
|
return new ExceptionHandlerExceptionResolver(); |
|
|
|
return new ExceptionHandlerExceptionResolver(); |
|
|
|
|