From 2d89a8253cf4fc23dee831256a75730fcbba68d9 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Tue, 31 Aug 2021 16:37:38 -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 240e780744..086ce6a606 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 @@ -401,7 +401,7 @@ public class WebMvcProperties { /** * 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 39e6e92bdb..f4a438d1d0 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 @@ -837,7 +837,8 @@ class WebMvcAutoConfigurationTests { @Test @Deprecated 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();