There are two classes involved on parsing URI Templates.
AntPathMatcher.extractUriTemplateVariables()
: Used in@RequestMapping
MVC annotationUriTemplate
: Used in RestTemplate client.
You can use these classes to test how the URI Templates are parsed.
For example for MVC RequestMapping:
@RunWith(BlockJUnit4ClassRunner.class)
public class UriTemplateTest {
private AntPathMatcher matcher = new AntPathMatcher();
private Log log = LogFactory.getLog(UriTemplateTest.class);
@Test
public void testUriTemplate() {
Map<String, String> variables = matcher.extractUriTemplateVariables("/booking/hotel/{id}", "/booking/hotel/43");
log.info(variables);
}
}