org.apache.http.ProtocolException: Target host is not specified

后端 未结 3 1116
囚心锁ツ
囚心锁ツ 2021-01-17 07:22

I have written a simple httprequest/response code and I am getting this below error. I have referenced httpclient, httpcore, common-codecs and common-logging in my classpath

相关标签:
3条回答
  • 2021-01-17 07:57

    This error is probably caused by the wrong url. Check the url:

    1. protocal missing;
    2. url parameters encode;
    0 讨论(0)
  • 2021-01-17 08:06

    The error message is kind of misleading. You've provided a value that does not represent a complete URI

    request = new HttpGet("trib.me/1lBFzSi");
    

    It's missing a protocol.

    Simply provide a complete URI

    request = new HttpGet("http://trib.me/1lBFzSi");
    
    0 讨论(0)
  • 2021-01-17 08:12

    In my case I solvid adding / at the beggining: request = new HttpGet("/trib.me/1lBFzSi");

    0 讨论(0)
提交回复
热议问题