且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用于解析URI的Spring实用程序

更新时间:2023-01-14 14:37:45

这就是:

    String format = "location/{state}/{city}";
    String actualUrl = "location/washington/seattle";
    AntPathMatcher pathMatcher = new AntPathMatcher();
    Map<String, String> variables = pathMatcher.extractUriTemplateVariables(format, actualUrl);
    assertThat(variables.get("state"), is("washington"));
    assertThat(variables.get("city"), is("seattle"));