slipheed
slipheed

Reputation: 7278

In Spring's RequestMapping, is {parameter:.+} any different than {parameter}

I'm looking at some Spring code that uses a RequestMapping like so:

@RequestMapping("/foo/{bar:.+}")

Is this functionally any different than the following?

@RequestMapping("/foo/{bar}")

From what I can tell the RegExp is always applied to the segment between slashes, so the two should be equivalent (although maybe .+ might say "non-empty?).

I suppose another way to phrase the question might be:

Is Spring's {bar} equivalent to {bar:.*} or {bar:.+}?

Upvotes: 3

Views: 289

Answers (2)

Biju Kunjummen
Biju Kunjummen

Reputation: 49925

Verified using a small test - it is @RequestMapping("/foo/{bar:.+}") the reason is if it is .*, it means that /foo/ and /foo/something will map to the same request mapped method, which it will not.

Upvotes: 2

jamb
jamb

Reputation: 196

.+ -> says 1 or more
.* -> would say 0 or more...

Upvotes: 1

Related Questions