这是我在jsp中的代码:
<c:catch var="feederror">
<%
String feedUrl = (String) pageContext.getAttribute("url");
String feedXml = "";
HttpURLConnection conn = (HttpURLConnection) new URL(feedUrl).openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line;
while ((line = reader.readLine()) != null) {
feedXml += line;
}
reader.close();
pageContext.setAttribute("feedXml", feedXml.trim().replaceAll("",""));
%>
</c:catch>
变量 feederror 返回java.net.ProtocolException:服务器重定次数过多(20)。
我尝试过:
如何解决该问题?
答案 0 :(得分:1)
java.net.ProtocolException:服务器重定了太多次(20)。
此异常来自HttpURLConnection conn =(HttpURLConnection)新的URL(feedUrl).openConnection();
对于99%的用户,您正在调用一个url,该URL向自身发送重定向,或向站点B发送重定向,该站点B重定向至站点A,该站点重定向至站点B等,因此存在循环。
检查您要调用的URL并通过一些外部工具进行验证,以便您可以检查外部服务器的标头和响应。
我认为与Cookie无关