Apply PathPatternParser also to BeanNameUrlHandlerMapping
Closes gh-26414
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -514,6 +514,16 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
|
||||
BeanNameUrlHandlerMapping mapping = new BeanNameUrlHandlerMapping();
|
||||
mapping.setOrder(2);
|
||||
|
||||
PathMatchConfigurer pathConfig = getPathMatchConfigurer();
|
||||
if (pathConfig.getPatternParser() != null) {
|
||||
mapping.setPatternParser(pathConfig.getPatternParser());
|
||||
}
|
||||
else {
|
||||
mapping.setUrlPathHelper(pathConfig.getUrlPathHelperOrDefault());
|
||||
mapping.setPathMatcher(pathConfig.getPathMatcherOrDefault());
|
||||
}
|
||||
|
||||
mapping.setInterceptors(getInterceptors(conversionService, resourceUrlProvider));
|
||||
mapping.setCorsConfigurations(getCorsConfigurations());
|
||||
return mapping;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,7 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.handler.HandlerExceptionResolverComposite;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver;
|
||||
@@ -332,6 +333,14 @@ public class DelegatingWebMvcConfigurationTests {
|
||||
assertThat(mapping.getPatternParser()).isSameAs(patternParser);
|
||||
configAssertion.accept(mapping.getUrlPathHelper(), mapping.getPathMatcher());
|
||||
|
||||
BeanNameUrlHandlerMapping beanNameMapping = webMvcConfig.beanNameHandlerMapping(
|
||||
webMvcConfig.mvcConversionService(),
|
||||
webMvcConfig.mvcResourceUrlProvider());
|
||||
|
||||
assertThat(beanNameMapping).isNotNull();
|
||||
assertThat(beanNameMapping.getPatternParser()).isSameAs(patternParser);
|
||||
configAssertion.accept(beanNameMapping.getUrlPathHelper(), mapping.getPathMatcher());
|
||||
|
||||
assertThat(webMvcConfig.mvcResourceUrlProvider().getUrlPathHelper()).isSameAs(pathHelper);
|
||||
assertThat(webMvcConfig.mvcResourceUrlProvider().getPathMatcher()).isSameAs(pathMatcher);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user