在restTempalte Spring Boot中发送参数

时间:2019-12-18 14:10:06

标签: spring-boot get resttemplate

我正在尝试在春季启动时发送带有RestTemplate的get,发送查询参数 在以下问题上:

        String url = "https://X.X.X.X/X/X/loren/value?token={token}";
        this.restTemplate.getForObject(url, String.class, "X");

并且在运行代码时出现以下错误:


org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://X.X.X.X/X/X/loren/value": Connect to X.X.X.X:port [X.X.X.X/1.1.1.1] failed: Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException: Connect to X.X.X.X:port [X.X.X.X/1.1.1.1] failed: Connection refused (Connection refused)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:751) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:677) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]
    at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:318) ~[spring-web-5.2.2.RELEASE.jar:5.2.2.RELEASE]

据我所知,它没有向我发送参数。我有办法发送该参数吗? 谢谢

0 个答案:

没有答案