Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PathMatcher to PathPatternParser migration in mvc XML configuration #34064

Closed
bclozel opened this issue Dec 10, 2024 · 0 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Dec 10, 2024

As of Spring Framework 6.0, several path matching options have been deprecated and the PathPatternParser is being chosen by default over the AntPathMatcher. The Java configuration upgrade has been done progressively and deprecated options are going to be retired in #34036 and #34018.

We received feedback from customers about gaps in the upgrade experience in the mvc XML configuration namespace. While this configuration option is going to be deprecated itself in #34063, we should ensure that the upgrade experience is good.

Targeting this issue for 6.2.x with backports in 6.1.x and commercial versions.

@bclozel bclozel added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement labels Dec 10, 2024
@bclozel bclozel added this to the 6.2.x milestone Dec 10, 2024
@bclozel bclozel self-assigned this Dec 10, 2024
@bclozel bclozel modified the milestones: 6.2.x, 6.2.2 Dec 17, 2024
@bclozel bclozel added the for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x label Dec 17, 2024
@github-actions github-actions bot added status: backported An issue that has been backported to maintenance branches and removed for: backport-to-6.1.x Marks an issue as a candidate for backport to 6.1.x labels Dec 17, 2024
bclozel added a commit that referenced this issue Dec 17, 2024
Prior to this commit, the MVC namespace for the XML Spring configuration
model would use the `PathMatcher` bean instance when provided like this:

```
<bean id="pathMatcher" class="org.springframework.util.AntPathMatcher"/>
<mvc:annotation-driven>
  <mvc:path-matching path-matcher="pathMatcher"/>
</mvc:annotation-driven>
<mvc:resources mapping="/resources/**" location="classpath:/static/"/>
```

With this configuration, the handler mapping for annotated controller
would use the given `AntPathMatcher` instance but the handler mapping
for resources would still use the default, which is `PathPatternParser`
since 6.0.

This commit ensures that when a custom `path-matcher` is defined, it's
consistently used for all MVC handler mappings as an alias to the
well-known bean name. This allows to use `AntPathMatcher` consistently
while working on a migration path to `PathPatternParser`

This commit also adds a new XML attribute to the path matching
configuration that makes it possible to use a custom `PathPatternParser`
instance:

```
<bean id="patternParser" class="org.springframework.web.util.pattern.PathPatternParser"/>
<mvc:annotation-driven>
  <mvc:path-matching pattern-parser="patternParser"/>
</mvc:annotation-driven>
```

Closes gh-34102
See gh-34064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: backported An issue that has been backported to maintenance branches type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant