[英]java.lang.IllegalStateException: Target host is null
I have googled but many concerns was " java.lang.IllegalStateException: Target host must not be null ", but in my case error was " java.lang.IllegalStateException: Target host is null " 我已经用谷歌搜索,但是很多担心是“ java.lang.IllegalStateException:目标主机不能为空 ”,但在我的情况下,错误是“ java.lang.IllegalStateException:目标主机为空 ”
I am trying to post a request using following code 我正在尝试使用以下代码发布请求
StringEntity reqContent = new StringEntity(xmlData);
reqContent.setContentType("text/xml");
HttpPost req = new HttpPost(serverURL);
req.setEntity(reqContent);
httpClient = new DefaultHttpClient(connMgr, params);
httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
HttpResponse response = httpClient.execute(req);
After executing the request I am getting "Target host is null". 执行请求后,我得到“目标主机为空”。 I am giving a valid host.
我给一个有效的主机。 Does this error comes when Target host which I am trying to access is not available?
当我尝试访问的目标主机不可用时,会出现此错误吗?
发送请求时,我想发送请求的URL变得空,这在我尝试执行请求时导致了此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.