Java HttpURLConnection getFollowRedirects() 方法

2025年3月22日 | 阅读1分钟

getFollowRedirects() 是 HttpURLConnection 类的一个方法。此方法用于指示是否应自动跟随 HTTP 重定向(3xx)。

语法

返回值

如果自动跟随 HTTP 重定向,则返回 true,否则返回 false。

示例 1

输出

getFollowRedirects : true
connecion disconnected

示例 2

输出

getFollowRedirects :true
www.oracle.com
getFollowRedirects :true
connection disconnected