注销后,登录页面无法打开

时间:2013-01-15 11:27:39

标签: spring redirect extjs spring-security logout

由于某些原因,我有一个spring应用程序,它有两个用extjs编写的客户端应用程序。一个只包含登录页面,另一个包含应用程序逻辑。在Spring中,我将它们包含在我正在控制器中使用的两个jsp页面中。

登录和重定向到应用程序页面工作正常。但是,如果我注销注销成功,但我一直停留在应用程序页面上,而不是被重定向到登录页面。

安全配置:

<security:logout logout-url="/main/logoutpage.html" delete-cookies="JSESSIONID" invalidate-session="true" logout-success-url="/test/logout.html"/>

控制器:

@RequestMapping(value="/test/logout.html",method=RequestMethod.GET)
public ModelAndView testLogout(@RequestParam(required=false)Integer error, HttpServletRequest request, HttpServletResponse response){
    return new ModelAndView("login");
}

“login”是包含登录应用程序的视图的名称。在浏览器调试中,我可以看到以下两个通信:

    Request URL:http://xx:8080/xx/xx/logoutpage.html?_dc=1358246248972
Request Method:GET
Status Code:302 Moved Temporarily
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=6E22E42CC6835C8A6DFF2535907DEF17
Host:xx:8080
Referer:http://xx:8080/xx/xx/Home.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
X-Requested-With:XMLHttpRequest
Query String Parametersview URL encoded
_dc:1358246248972
Response Headersview source
Content-Length:0
Date:Tue, 15 Jan 2013 10:37:33 GMT
Location:http://xx:8080/xx/xx/login.html
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/xx



Request URL:http://xx:8080/xx/xx/login.html
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Cookie:JSESSIONID=6E22E42CC6835C8A6DFF2535907DEF17
Host:xx:8080
Referer:http://xx:8080/xx/xx/Home.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
X-Requested-With:XMLHttpRequest
Response Headersview source
Content-Language:de-DE
Content-Length:417
Content-Type:text/html;charset=ISO-8859-1
Date:Tue, 15 Jan 2013 10:37:33 GMT
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=532EBEED737BD4172E290F0D10085ED5; Path=/xx/; HttpOnly

第二个响应还包含登录页面:

    <html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <script src="http://extjs.cachefly.net/ext-4.1.1-gpl/ext-all.js"></script>
    <link rel="stylesheet" href="http://extjs.cachefly.net/ext-4.1.1-gpl/resources/css/ext-all.css">
    <script type="text/javascript" src="/xx/main/app/app.js"></script>
</head>
<body></body>
</html>

有人知道为什么登录页面没有显示?

由于

2 个答案:

答案 0 :(得分:0)

“一个只包含登录页面而另一个包含应用程序逻辑”是什么意思?你有2个应用程序? 2个不同的WAR / JAR?

请解释......

BTW - 注销后,您希望将用户重定向到应用中的受保护资源,然后 Spring 会将用户重定向到登录页面。您不必(或不应)自己隐式重定向到登录页面。

答案 1 :(得分:0)

而不是用于注销控制的自定义JavaScript处理程序,只需使用普通链接:

<a href="/main/logoutpage.html">Logout</a>

Logout控制器使用 HTTP重定向来显示登录页面。在AJAX的情况下,调用重定向不能像你想要的那样工作。查看AJAX调用的XmlHttpResponse。你会在那里找到退出页面。