Skip to content

Adapt to change in default strategy for URL path matching in Spring MVC #31547

@rstoyanchev

Description

@rstoyanchev

Currently WebMvcAutoConfiguration sets a PathPatternParser if the matching-strategy is PATH_PATTERN_PARSER but doesn't do anything if it is ANT_PATH_MATCHER since AntPathMatcher is used by the default.

After the changes in spring-projects/spring-framework#28607, parsed patterns are enabled by default, in Spring Framework 6.0, and that will require a review and likely some changes in the Boot auto-configuration to ensure the properties continue to work as expected.

First, it is now necessary to explicitly enable String path matching when it is needed. This can be done either by explicitly setting PathMatchConfigurer#patternParser to null. Second, technically a PathPatternParser does not need to be set externally in order to enable parsed patterns.

Do keep in mind, however, that if any AntPathMatcher related properties on PathMatchConfigurer are set, that could enable String path matching, if a PathPatternParser is not explicitly set. Generally, an application should not set the matching-strategy to PATH_PATTERN_PARSER and at the same time set AntPathMatcher related properties, as those are mutually exclusive. If both are set, then PathPatternParser takes precedence, but if only AntPathMatcher related properties are set then String path matching is enabled.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions