Spring 弹簧组件生成器
我有一个包含编码部分和变量的字符串Spring 弹簧组件生成器,spring,uri,Spring,Uri,我有一个包含编码部分和变量的字符串 https://example.com/foo%2Fbar/{variable} 我正在尝试创建一个URI对象,如下所示: String s = "https://example.com/foo%2Fbar/{0}" URI uri = UriComponentsBuilder.fromHttpUrl(s) .buildAndExpand("baz") .t
https://example.com/foo%2Fbar/{variable}
我正在尝试创建一个URI对象,如下所示:
String s = "https://example.com/foo%2Fbar/{0}"
URI uri = UriComponentsBuilder.fromHttpUrl(s)
.buildAndExpand("baz")
.toUri();
结果是https://example.com/foo%252Fbar/baz
但我想得到https://example.com/foo%2Fbar/baz
如何确保变量已展开,但避免再次对已编码部分进行编码