Spring RestTemplate抛出IllegalArgumentException:不是有效的HTTP URL

0 java rest spring spring-mvc resttemplate

java.lang.IllegalArgumentException:[https:// localhost/pcap/search?stime = 20110930%2E000000&etime = 20110930%2E235959&bpf = tcp

这是我使用Spring RestFul模板进行的调用:

final PcapSearchResponse pcapSearchResult = restTemplate.postForObject(
    nPulseApiUris.get(2), null, PcapSearchResponse.class, sTime, eTime, bpf);
Run Code Online (Sandbox Code Playgroud)

我不明白为什么这是一个糟糕的URL?我用UTF-8编码"." 字符,但我不知道为什么我的网址仍然无效.

非常感谢您的帮助!

谢谢您的帮助!!!

Boz*_*zho 5

文件中RestTemplate提到:

此外,String-argument方法假定URL String是未编码的.

因此,当您将URL作为字符串传递时,请不要对其进行编码.春天会照顾到这一点.