From ab8e599cfedd6d626daaee65fc86d8c0ae470d16 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 7 Apr 2021 10:59:23 -0700 Subject: [PATCH] Switch default MVC path matching strategy Change the default `spring.mvc.pathmatch.matching-strategy` to `PATH_PATTERN_PARSER`. Closes gh-24805 --- .../boot/autoconfigure/web/servlet/WebMvcProperties.java | 2 +- .../web/servlet/WebMvcAutoConfigurationTests.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java index 2a8669c2d1dc..5f53ea2a6165 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java @@ -434,7 +434,7 @@ public static class Pathmatch { /** * 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. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java index 3e929144d28a..e9c314fc0370 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java @@ -849,7 +849,8 @@ void defaultPathMatching() { @Deprecated @SuppressWarnings("deprecation") 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) -> { RequestMappingHandlerMapping handlerMapping = context.getBean(RequestMappingHandlerMapping.class); assertThat(handlerMapping.useSuffixPatternMatch()).isTrue();