1

由于某些原因,我有一个 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>

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

谢谢

4

2 回答 2

0

Instead of custom JavaScript handler for logout control just use a normal link:

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

Logout controller uses HTTP redirect to show login page. In a case of AJAX call redirect does not work like you want. Look into XmlHttpResponse of your AJAX call. You will find the logout page there.

于 2013-01-15T13:27:18.477 回答
0

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

请解释...

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

于 2013-01-15T12:19:17.727 回答