- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了一个问题,我想它必须很容易解决,但我坚持了下来。
这是我的代码片段:
String url = UriComponentsBuilder.fromPath("http://localhost")
.build().toUriString();
url
的值为:
http:/localhost
如您所见,://
被替换为 :/
关于如何解决这个问题有什么想法吗?
最佳答案
fromPath
将仅采用 API 或资源路径,例如 /api/student
。但它并不像您的情况那样需要整个网址。一种替代方案是,
UriComponentsBuilder.fromUriString("http://localhost")
.build().toUriString();
或者也可以使用以下方法完成相同的操作:
UriComponentsBuilder.newInstance().scheme("http").host("localhost").build().toString();
关于java - 字符串启动 : UriComponentsBuilder toString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53853842/
嘿,我有这个包含多个查询参数的网址 - 它用于搜索。这是一个仇恨链接 https://someurl/customers?customer-id={customer-id}&type={type}&s
我正在使用UriComponentsBuilder: UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("com.st
我在学习 spring boot 时得到了一个 UriComponentsBuilder 示例。不知道UriComponentsBuilder的含义和UriComponentsBuilder的作用。
我正在尝试构造一个 url UriComponentsBuilder。 UriComponentsBuilder.fromUriString(BASE) .pathSe
我遇到了一个问题,我想它必须很容易解决,但我坚持了下来。 这是我的代码片段: String url = UriComponentsBuilder.fromPath("http://localhost"
我很难理解 UriComponentsBuilder 的行为.我想用它对查询参数中的 URL 进行编码,但它似乎只转义 % 字符,而不转义其他必要的字符,例如 &。 查询参数中根本未编码的 URL 示
我有以下代码: String convertedBuilder = builder.toUriString(); convertedBuilder = convertedBuilder
我最近切换到 Spring 来使用 ServiceNow 托管的 REST API 调用。 我正在构建我的 URI,如下所示: UriComponentsBuilder builder = UriCo
我有一个如下所示的路径:/service/method/{id}/{parameters},我使用restTemplate调用它,其中/service/method是一个微服务,{id} 是我需要询问
在 UriComponentsBuilder 中使用 Expand() 和直接添加值有什么不同? //#1 String uri = UriComponentsBuilder.fromUriStrin
UriComponentsBuilder 的文档建议转换为 java.net.URI 是可能的,但并不直接。 以下似乎可行,但涉及通过 toUriString() 进行的中间序列化。 UriCompo
我正在尝试使用 spring 的 UriComponentsBuilder 为 oauth 交互生成一些 url。查询参数包括回调url和参数值等实体,其中包含空格。 尝试使用 UriComponen
为了将我的 Java SpringBoot 应用程序与常规 REST 端点集成,我使用此方法来准备 URI import org.springframework.web.util.UriCompone
我有一个方法,它接受一些参数并从中形成一个 URI,以便访问我们的客户端 REST 服务。这些参数之一可能出现空格。问题是 UriComponentsBuilder.pathSegment 忽略了空间
您好,如何使用“http://test.com/#/signup ”成功创建 UriComponentsBuilder?以下代码将抛出无效的 HTTP url。 UriComponentsBuilde
我是一名优秀的程序员,十分优秀!