0
我用Google搜索,但許多關切是「java.lang.IllegalStateException:目標主機不能爲空」,但在我的情況下,錯誤是「java.lang.IllegalStateException :目標主機爲null「java.lang.IllegalStateException:目標主機爲null
我嘗試使用下面的代碼
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);
執行我收到請求後發佈的請求‘目標主機是空’。 我給一個有效的主機。當我嘗試訪問的目標主機不可用時,是否出現此錯誤?