I have following method in controller:
@RequestMapping(value = "/items/{identifier}", method = RequestMethod.DELETE)
public void delete(@PathVariable String identifier) {
...
// find item in database by identifier
}
The problem is identifier is a String that can contain slash ('/'). I.e. situation can occurs:
http://myhost/items/file:/123
For given URL 'identifier' must be "file:/123".
And if there is a '/', 405 (method is not allowed) throws due to incorrect URL.
How to tell Spring that it should take all after '/items/' as 'identifier' (resource name in REST terms)?
EDIT: I was told that it is client's responsibility to manage slashes and encoding, so I left it as it was.
But for the info, based on ankur-singhal answer in comments:
Support that I wanted to was added in Spring 4.1.0, see this link and this commit. So in my case it'll be:
@RequestMapping(value = "/items/{/identifier}", method = RequestMethod.DELETE)
'/' before 'identifier' did a trick.