Possible Duplicate:
Spring 3 RequestMapping: Get path value
In Spring 3, is there a way to capture rest/of/the/url
in the following URL:
/myapp/foo/bar/rest/of/the/url
by using a @RequestMapping annotation like this:
@RequestMapping(value="{appname}/{path1}/{path2}/{remainder}")
public String myRequestMethod(
@PathVariable("appname") String appName,
PathVariable("path1") String path1,
PathVariable("path2") String path2,
PathVariable("remainder") String remainder)
I would like the RequestMapping to match like this
{appname} -> myapp
{path1} -> foo
{path2} -> bar
{remainder} -> rest/of/the/url
In the Javadocs for RequestMapping there is a note about using an alternate regular expression:
By default, the URI template will match against the regular expression [^.]* (i.e. any character other than period), but this can be changed by specifying another regular expression, like so: /hotels/{hotel:\d+}
But this doesn't behave as expected (I get 404) when I use a RequestMapping like so:
@RequestMapping(value="{appname}/{path1}/{path2}/{remainder:.[\\S]*}")
Does anyone know how to match the rest of an URL with a Spring RequestMapping?