new url()报no protocol

在发Http请求时发现了new(reqUrl, 3000, 3000)一直为null,日志报的一直是空指针,直到断点到以下部分才发现是new Url()出错,报no protocol

public HttpClient(String url, int connectionTimeout, int readTimeOut) {
        try {
            this.url = new URL(url);
            this.connectionTimeout = connectionTimeout;
            this.readTimeOut = readTimeOut;
        } catch (MalformedURLException e) {
            logger.info(e.getMessage());
        }
}

  

解决方案:

加上http://或https://

posted @ 2020-11-10 18:28  时间会有答案  阅读(1030)  评论(0)    收藏  举报