【发布时间】:2013-04-24 10:19:59
【问题描述】:
我有下一个代码
URL targetUrl = ...
HttpClient client = new HttpClient(connectionManager);
GetMethod getMethod = new GetMethod();
getMethod.setPath(targetUrl.getPath());
HostConfiguration hostConfiguration = getConfiguration(targetUrl) //unknown lib code
client.executeMethod(hostConfiguration, getMethod);
在某些情况下(在某些主机上)我得到 p>
java.lang.IllegalArgumentException: host parameter is null"
关于 client.executeMethod 调用。
为什么会发生这种情况?
【问题讨论】:
-
当我没有在我的 URL 前写“http://”时收到此错误。也许你也应该试试
-
目前我调试了代码。原因是主机未设置为 HostConfiguration,但已设置 proxyHost。那么我应该在设置 proxyHost 时设置主机还是这是错误?
-
这种情况下不需要HostConfiguration,看这个教程:hc.apache.org/httpclient-legacy/tutorial.html