Http状态码:简单获取http状态码

    public static void main(String[] args) {
        try {
            String str = "https://www.baidu.com/";
            URL url = new URL(str);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.connect();
            int responseCode = connection.getResponseCode();
            System.out.println(responseCode);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

执行结果:
Http状态码:简单获取http状态码

上一篇:uniapp——easy-git代码管理


下一篇:Postman: Test