【问题标题】:org.javalite.http.HttpException: Failed URL: "https://google.in"org.javalite.http.HttpException:失败的 URL:“https://google.in”
【发布时间】:2017-01-18 05:10:31
【问题描述】:

我在测试 API GET 调用的 Javalite 中执行简单程序时遇到问题。

该方法获取 URL 并读取响应代码。但是 JavaLite 抛出异常:

org.javalite.http.HttpException: Failed URL: "https://google.in"

有人可以帮我理解这个问题吗?

我的代码是:

package com.java.lite;

import org.javalite.http.Get;
import org.javalite.http.Http;
import org.testng.annotations.Test;

public class GetCallTest {

    @Test
    public void getCall() throws Exception {
        System.out.println(ConfigPropertyFile.getPropertyValues()); //This line is executed

        Get get = Http.get(ConfigPropertyFile.getPropertyValues()); //URL being call from another class where I defined a static method.
        System.out.println("Response code" + get.responseCode());
        System.out.println("Response message = `enter code here`" + get.responseMessage());
    }
}

【问题讨论】:

  • 请包含整个例外情况

标签: httpexception javalite


【解决方案1】:

您尝试的 URL 将重定向到 https://www.google.co.in/

请尝试:

System.out.println(Http.get("https://www.google.co.in/").text());

您将获得 Google 主页的文本。

【讨论】:

    猜你喜欢
    • 2012-12-11
    • 2014-02-25
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 2015-10-09
    • 1970-01-01
    • 2012-06-11
    • 2018-07-05
    相关资源
    最近更新 更多