当前位置:   article > 正文

HttpClient:Target host must not be null, or set in parameters

HttpClient:Target host must not be null, or set in parameters
HttpClient client = new DefaultHttpClient();  
HttpGet get = new HttpGet("www.baidu.com");  
HttpResponse response = client.execute(get); 
抛出异常: Target host must not be null, or set in parameters
原因是:url写法错误,需要加上http://
解决办法:将" www.baidu.com "改为" http://www.baidu.com"
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/282291
推荐阅读
相关标签
  

闽ICP备14008679号