![](/img/trans.png)
[英]@PreAuthorize(“isAuthenticated()”) redirected server too many times
[英]Server redirected too many times
從應用程序運行時,出現以下異常,但是當我獨立運行時,得到其余的呼叫響應位置,可以幫助我解決此問題。
java.net.ProtocolException:服務器重定向太多次(20)
public static void main(String args[]) throws Exception{
String input = new String();
Authenticator.setDefault(new MyAuthenticator());
StringBuffer url = new StringBuffer();
url.append("https://rest-call-server-URL");
URL page;
try {
page = new URL(url.toString());
URLConnection conn = (URLConnection) page.openConnection();
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
input+=inputLine;
System.out.println(inputLine);
}
in.close();
// out.close();
//parseXmlList(input);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
您極有可能在服務器上進入了重定向循環。 服務器以303 See other
響應,並且當Java的URL連接實現自動“看到其他”時,服務器將再次以相同的響應進行響應,依此類推。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.