0
我試圖將User Service與用戶服務進行交互以限制訪問。該應用程序在eclipse中運行良好,但是一旦我將其部署到應用程序引擎,它就不會按預期重定向到Google登錄頁面,但會出現錯誤: 服務器錯誤 服務器遇到錯誤,無法完成您的請求。 請在30秒後重試。 這是用於在servlet的一部分:與用戶服務一起使用時,App Engine返回錯誤
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
public class MyLogin extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
UserService userService = UserServiceFactory.getUserService();
String thisURL = "/home.html";
resp.setContentType("text/html");
if (req.getUserPrincipal() != null) {
resp.getWriter().println("<p>Hello, " +
req.getUserPrincipal().getName() +
"! You can <a href=\"" +
userService.createLogoutURL(thisURL) +
"\">sign out</a>.</p>");
} else {
resp.getWriter().println("<p>Please <a href=\"" +
userService.createLoginURL(thisURL) +
"\">sign in</a>.</p>");
}
}
}
我建議您查看控制檯中的App Engine日誌並檢查錯誤日誌。它會給你更詳細的問題。 – Romin
感謝您的回覆。我真的做了,並一直指向上面的文件。 –