3

Spring MVC の URI テンプレートがどのように解析されるかについて、決定的な答えを見つけようとしています。ドキュメンテーションはドラフト RFC にリンクしていますが、Spring はRFC の実装ページ 記載されていません。誰でも私のためにこれをクリアできるリンクを持っていますか?

4

2 に答える 2

1

Spring は RFC6570 をサポートしていませんが、

たとえば、最初は成功し、2 番目は失敗します。

@Test
public void thatUriPathVariablesWithSlashGetEncoded() {
    String uri = com.damnhandy.uri.template.UriTemplate.fromTemplate("http://localhost:80/context/entity/{var1}/{var2}").set("var1", "my/Id").set("var2", "blah").expand();

    Assert.assertThat(uri, Matchers.is("http://localhost:80/context/entity/my%2FId/blah"));
}

@Test
public void thatUriPathVariablesWithSlashGetEncodedWithSpring() {
    String uri = new org.springframework.web.util.UriTemplate("http://localhost:80/context/entity/{var1}/{var2}").expand("my/Id", "blah")
            .toASCIIString();

    Assert.assertThat(uri, Matchers.is("http://localhost:80/context/entity/my%2FId/blah"));
}

1 日サポートを追加するためのオープン チケットがあります。https://jira.spring.io/browse/SPR-10505

于 2015-04-21T00:50:27.290 に答える