UriTemplateUtil { static Map<String, String> extractUriTemplateVariables(String requestPath,String matchingPatternPath){ PathMatcher matcher = new AntPathMatcher(); Map<String, String> map = matcher.extractUriTemplateVariables(matchingPatternPath, requestPath); if (LOGGER.isDebugEnabled()){ LOGGER.debug("requestPath:[{}],matchingPatternPath:[{}],result:[{}]", requestPath, matchingPatternPath, JsonUtil.format(map)); } return map; } private  UriTemplateUtil(); static String getUriTemplateVariableValue(HttpServletRequest request,String pathVarName); static boolean hasPathVarName(HttpServletRequest request,String pathVarName); static Map<String, String> getUriTemplateVariables(HttpServletRequest request); static String getBestMatchingPattern(HttpServletRequest request); static String expandBestMatchingPattern(HttpServletRequest request,String variableName,String value); static String expandWithVariable(String requestPath,String matchingPatternPath,String variableName,String value); static String expandWithVariable(String matchingPatternPath,String variableName,String value); static String clearVariablesValue(String requestPath,String matchingPatternPath,String[] variableNames); static String retainVariablesValue(String requestPath,String matchingPatternPath,String[] variableNames); static String expand(String uriTemplatePath,Map<String, String> map); static List<String> getVariableNames(String uriTemplatePath);  }
@Test public void testExtractUriTemplateVariables(){ String requestPath = "/c/m-caaa-s-k-s-o.htm"; String matchingPatternPath = "/c{categoryCode}/m{material}-c{color}-s{size}-k{kind}-s{style}-o{order}.htm"; Map<String, String> map = UriTemplateUtil.extractUriTemplateVariables(requestPath, matchingPatternPath); LOGGER.debug("map:{}", JsonUtil.format(map)); }