我发布了一个带有下划线(_)的参数的网址.
样本:http://sdsdsds_asasasahjhd.com/dsdsdsd/login.json?
我发布的方式如下:
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://sdsdsds_asasasahjhd.com/dsdsdsd/login.json?");
try {
List nameValuePairs = new ArrayList(2);
nameValuePairs.add(new BasicNameValuePair("key1", "value1"));
nameValuePairs.add(new BasicNameValuePair("key2", "value2"));
nameValuePairs
.add(new BasicNameValuePair("key3", "value3"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (Exception e) {
e.printStackTrace();
}
当我检查httpclient.execute(httppost)时,我收到了IllegalArgumentException,并且在异常详细信息的catch中,它告诉主机名不能为null.
请指明任何解决方案.
我在这里经历了一些其他问题:
但没有用,因为我没有编码整个网址.