Itachi
Itachi

Reputation: 1433

Spring controller regex mapping

I have a url say /prefix/part1/part2/.../partN/suffix and in a controller i want to map anything between /prefix/ and /suffix to one variable.

Approaches tried

@RequestMapping(value = "/prefix/{store:[\s\S]*}/suffix",
            method = RequestMethod.GET)

Also, tried regex : (.*), The interesting part is i don't know what N is. So, cant explicitly specify number of slashes possible.

Upvotes: 0

Views: 273

Answers (1)

I have an open JIRA issue requesting this ability, but the Spring core team apparently doesn't think that it's useful and is not interested in supporting it. You might make a note there.

In the meantime, the only option is to get the entire string from the request and parse it yourself.

Upvotes: 2

Related Questions