0
我正在尝试为我的网站设置一个登录页面,但是此刻我卡在sendRedirect
方法中,因为它在需要时似乎不会加载新页面。response.sendRedirect在Java和AngularJS之间不起作用
我的登录页面是一个.jsp文件即会透过AngularJS $scope
到servlet的用户名和密码信息,其中包含以下代码:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
System.out.println("Redirecting...");
response.sendRedirect("https://www.youtube.com/");
return;
}
的System.out.println("Redirecting...");
的作品,但它不重定向到提供的网址,不管它是什么。我已阅读其他建议,其中提到添加return;
行,并且我尝试过其他URL专用于我的项目(例如index.jsp
,\index.jsp
等),但这些都没有改变,它仍然无法正常工作。
window.location
会更合适吗?我应该在这里修改哪些代码?
定义_doesn't WORK_。你为什么期望你的页面重定向,而不是通过AngularJS发送的请求?当您在浏览器的网络控制台中检查响应的状态代码时,它是什么? –
我的意思是浏览器不会从登录页面重定向到我在'response.sendRedirect'方法中指定的内容(例如youtube.com,index.jsp等) – dat3450
为什么要这样? –