【问题标题】:Redirect loop on my web app on Google App EngineGoogle App Engine 上我的网络应用程序上的重定向循环
【发布时间】:2015-01-15 06:03:34
【问题描述】:

我试图在网站上搜索我的问题,但没有成功。

我创建了一个 JSP Web 应用程序并部署在 Google App Engine 上。它不使用 Google 帐户身份验证,而是使用 Parse.com 作为后端数据存储。 “login.jsp”是它的欢迎文件。当我在 GAE 上点击 Firefox 上的“http://{project-name}.appspot.com”之类的 URL 时,它显示:

The page isn't redirecting properly

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

This problem can sometimes be caused by disabling or refusing to accept cookies.

我去Firebug发现“GET login.jsp”被自动调用了20多次。

当我用 Chrome 尝试它时,它返回了一条不同但相似的消息:

This webpage has a redirect loop

The webpage at http://{project-name}.appspot.com/login.jsp has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
Learn more about this problem.
Error code: ERR_TOO_MANY_REDIRECTS

有什么想法吗?

EDIT --- login.jsp 的代码如下

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
    <title>Log in</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css" />
    <style>
    .alert-info {
        font-weight: bold;
        margin-bottom: 4px;
        padding: 8px 14px;
    }

    .full-layout { padding:2%; }
    </style>
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
    <script type="text/javascript">
        $.mobile.ajaxEnabled = false;
    </script>
</head>

  <body>
  <div class="full-layout">
    <h1>Log in</h1>
    <% String alertMsg = (String) request.getSession().getAttribute("loginResultMsg");
        if (alertMsg != null) {
    %>
        <%= alertMsg %>     
    <% } %>
    <form action="LoginServlet" method="post">
        Name:<input type="text" name="name"><br>
        Password:<input type="password" name="password"><br>
        <input type="submit" value="Log in">
    </form>
    <%  request.getSession().setAttribute("loginResultMsg", null); %>
</div>
<%@include file="footer.jsp" %>
</body>
</html>

Firebug 的网络控制台已记录:

GET login.jsp

状态为“302 Found”。 “响应”是“重新加载页面以获取来源:http://{PROJECT_ID}.appspot.com/login.jsp”

奇怪的是,Web 应用程序在本地开发环境中运行良好,但在 GEA 上部署时却失败了。

【问题讨论】:

  • 你能发布你的 login.jsp 吗?基本上 login.jsp 正在向自身发送重定向。这可能是因为您的 login.jsp 中的代码或您的应用程序中的一些其他过滤器或 servlet。
  • 你能看到你从最初的GET login.jsp得到的响应,看看它重定向到的确切网址吗?这可能会帮助您调试代码。
  • 我会为@nhylated 点个赞。谢谢

标签: java jsp google-app-engine parse-platform


【解决方案1】:

可以在 GAE 上执行的重定向峰值数量为 25。这是为了防止无限循环。

因此,如果您遇到此错误,请确保您没有陷入无限循环。

【讨论】:

    【解决方案2】:

    我在网络应用中有一个 SessionFilter。由于 GAE 不支持 SessionFilter,因此在我删除此过滤器后,Web 应用程序在 GEA 上运行良好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多