I would like to extract the path variables and request parameters from the URL using existing Spring functions. I have a path format string that is valid for MVC @RequestMapping or UriComponentsBuilder . I also have a real way. I would like to extract path variables from this path.
For instance.
String format = "location/{state}/{city}"; String actualUrl = "location/washington/seattle"; TheThingImLookingFor parser = new TheThingImLookingFor(format); Map<String, String> variables = parser.extractPathVariables(actualUrl); assertThat(variables.get("state", is("washington")); assertThat(variables.get("city", is("seattle"));
This is a bit of a converse to UriComponentsBuilder , which from my reading of Javadocs does not have any parsing functions.
source share