2013-04-22 51 views
0

當在我的春季安全的應用程序註銷不工作,我有我的註銷按鈕放在下面的代碼春季安全:具有長期的相對路徑

<li><a href="<c:url value="j_spring_security_logout"/>">Log out</a></li> 

現在,當我的網址http://localhost:8080/servletname,註銷工作正常。

即使它是http://localhost:8080/servletname/abc它工作正常。

但是,當URL是http://localhost:8080/servletname/abc/xyz,當我點擊註銷按鈕時,我得到一個404頁面,因爲頁面被重定向到http://localhost:8080/servletname/abc/j_spring_security_logout

我該如何解決這個問題?

回答

0

「>登錄outsee link特別是部分:

Given a base URL and a relative URL (that does not begin with a slash), a full URL is derived as follows: 

If the base URL ends with a slash the full URL is derived by appending the relative URL to the base URL. For example, if the base URL is http://nosite.com/dir1/dir2/ and the relative URL is gee.html, the derived URL is http://nosite.com/dir1/dir2/gee.html. 
If the base URL doesn't end with a slash, the last piece of the base URL is considered a resource, so the full URL is derived by appending the relative URL to the parent of the base URL. For example, if the base URL is http://nosite.com/dir1/dir2 and the relative URL is gee.html, the derived URL is http://nosite.com/dir1/gee.html 

您使用相對路徑,使其絕對用 「/」 的網址開頭:

<a href="<c:url value="/j_spring_security_logout"/>">Log out</a> 
+0

它不工作..它被重定向到http:// localhost:8080/j_spring_security_logout – shazinltc 2013-04-22 12:04:13

+1

我認爲它應該是'">Log out' – Dani 2013-04-22 12:19:59

+0

@Dani:完美:)謝謝:) – shazinltc 2013-04-22 12:28:01