Skip to content

Matrix variables aren't read when path variable has regex restriction [SPR-11879] #16498

@spring-projects-issues

Description

@spring-projects-issues

Emerson Farrugia opened SPR-11879 and commented

I need to support a URI which looks like

/user/5/foo;a=1;b=2

where "foo" is a literal string. Since MVC only allows matrix variables on path variables, the corresponding request mapping looks like

/user/{userId}/{foo}

Since that would allow the foo variable to be anything, I restricted it using a regular expression, and the mapping became

/user/{userId}/{foo:foo}

At which point, my matrix variables stopped working. I've attached a Gist showing how matrix variables don't work when the path variable has a regex restriction. In that Gist, /withoutRegex/3 works with both matrix variables and without matrix variables. /withRegex/3 works without matrix variables, but when I specify matrix variables, I get the error

No mapping found for HTTP request with URI [/withRegex/3;q=10] in DispatcherServlet with name 'dispatcherServlet'


Affects: 4.0.5

Reference URL: https://gist.github.com/emersonf/d656611d174e32a3d9d3

Issue Links:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions