Reputation: 445
I have such method in my controller:
@RequestMapping("/action/{actionType:root/testaction}")
public String test( @PathVariable String actionType) {
}
When I do get request with url localhost/action/root/testaction
- this method is not called.
But when I change method like:
@RequestMapping("/action/root/{actionType:testaction}")
public String test( @PathVariable String actionType) {
}
And do the same get request - method works OK. The problem is that I want to include '/root' part into PathVariable string.
Could you clarify what can be wrong in my code?
Upvotes: 0
Views: 374
Reputation: 48654
The problem is that path variables may not contain "/" characters, because that makes the parsing harder.
The Spring @RequestMapping
feature partly implements RFC 6570: URI Template. That standard does not allow "/" characters in variable names:
variable-list = varspec *( "," varspec )
varspec = varname [ modifier-level4 ]
varname = varchar *( ["."] varchar )
varchar = ALPHA / DIGIT / "_" / pct-encoded
modifier-level4 = prefix / explode
prefix = ":" max-length
max-length = %x31-39 0*3DIGIT ; positive integer < 10000
explode = "*"
Upvotes: 1