1

我有一个关于 URI 模板变量的问题。

我需要使用以下形式管理 URI:

http://netlocation:port/application_path/{variable}

变量可以是路径本身,即类似

this/variable/is/a/path

这样完整的 URI 似乎是

http://netlocation:port/application_path/this/variable/is/a/path

我该怎么办?

4

3 回答 3

3

使用“+”运算符以避免转义“/”字符:

http://netlocation:port/application_path/{+foo}

你可以试试URI Template Parser Online

于 2012-12-06T13:55:35.393 回答
2

您可以使用查询参数并以标准方式对路径变量进行编码:

http://netlocation:port/application_path?path=%2Fthis%2Fvariable%2Fisapath
于 2011-12-13T19:25:40.007 回答
1

你看过http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/util/UriTemplate.html吗?

于 2012-01-04T20:12:07.350 回答