Google App Engine 上我的 Web 应用程序的重定向循环

Redirect loop on my web app on Google App Engine

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

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

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

有什么想法吗?

编辑 --- 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”。 "Response" 是 "Reload the page to get source for: http://{PROJECT_ID}.appspot.com/login.jsp"

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

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

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

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