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

时间:2011-10-20 18:31:06

标签: java spring rest spring-mvc resttemplate

  

java.lang.IllegalArgumentException异常:   [HTTPS://本地主机/ PCAP /搜索STIME = 20110930%2E000000&安培; ETIME = 20110930%2E235959&安培; BPF = TCP

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

final PcapSearchResponse pcapSearchResult = restTemplate.postForObject(
    nPulseApiUris.get(2), null, PcapSearchResponse.class, sTime, eTime, bpf);

我不明白为什么这是一个糟糕的网址?我用UTF-8编码“。”但我不确定为什么我的网址仍无效。

非常感谢您的帮助!

感谢您的帮助!!!

1 个答案:

答案 0 :(得分:5)

RestTemplate的文档提到:

  

此外,String-argument方法假定URL String未编码。

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