Switch default MVC path matching strategy"

Change the default `spring.mvc.pathmatch.matching-strategy` to
`PATH_PATTERN_PARSER`.

Closes gh-24805
This commit is contained in:
Madhura Bhave 2021-08-31 16:37:38 -07:00
parent b01fa6a899
commit 2d89a8253c
2 changed files with 3 additions and 2 deletions

View File

@ -401,7 +401,7 @@ public class WebMvcProperties {
/** /**
* Choice of strategy for matching request paths against registered mappings. * Choice of strategy for matching request paths against registered mappings.
*/ */
private MatchingStrategy matchingStrategy = MatchingStrategy.ANT_PATH_MATCHER; private MatchingStrategy matchingStrategy = MatchingStrategy.PATH_PATTERN_PARSER;
/** /**
* Whether to use suffix pattern match (".*") when matching patterns to requests. * Whether to use suffix pattern match (".*") when matching patterns to requests.

View File

@ -837,7 +837,8 @@ class WebMvcAutoConfigurationTests {
@Test @Test
@Deprecated @Deprecated
void useSuffixPatternMatch() { void useSuffixPatternMatch() {
this.contextRunner.withPropertyValues("spring.mvc.pathmatch.use-suffix-pattern:true", this.contextRunner.withPropertyValues("spring.mvc.pathmatch.matching-strategy=ant-path-matcher",
"spring.mvc.pathmatch.use-suffix-pattern:true",
"spring.mvc.pathmatch.use-registered-suffix-pattern:true").run((context) -> { "spring.mvc.pathmatch.use-registered-suffix-pattern:true").run((context) -> {
RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class); RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class);
assertThat(handlerMapping.useSuffixPatternMatch()).isTrue(); assertThat(handlerMapping.useSuffixPatternMatch()).isTrue();