Browse Source

Switch default MVC path matching strategy"

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

Closes gh-24805
pull/27861/head
Madhura Bhave 4 years ago
parent
commit
2d89a8253c
  1. 2
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java
  2. 3
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java

2
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcProperties.java

@ -401,7 +401,7 @@ public class WebMvcProperties { @@ -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.

3
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfigurationTests.java

@ -837,7 +837,8 @@ class WebMvcAutoConfigurationTests { @@ -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();

Loading…
Cancel
Save