Skip to content

@PathVariable drops extension [SPR-9333] #13971

@spring-projects-issues

Description

@spring-projects-issues

Will Glass-Husain opened SPR-9333 and commented

There's a bug introduced in 3.0.6 (also exists in 3.0.7) with the @PathVariable. It's very similar to #10038 though it was actually reintroduced in #13187.

If a item is included on the path that has a period, it's impossible for the full string to be picked up by the path variable. For example, with this URL and request mapping, userEmail is set to "jsmith@mail".

http://mydomain.com/myapp/api/user/[email protected]

and this method

@RequestMapping(value = {"/{userEmail}"}, method = RequestMethod.GET)
public ModelAndView doGet(@PathVariable final String userEmail)
{
}

My code also had a class-wide request mapping, though I'm not sure if it's relevant.

The usual advice is to include a DefaultAnnotationHandlerMapping in the context and set the property useDefaultSuffixPattern to false. However, in 3.0.6, code was introduced into AnnotationMethodHandlerAdapter.getMatchingPattern() which adds .* to the pattern (eliminating the so-called file extension) but which is not suppressed by useDefaultSuffixPattern.


Affects: 3.0.6, 3.0.7

Sub-tasks:

Referenced from: commits cf5d551, 8143d66

0 votes, 5 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions