0

在我的 Spring Security 应用程序中,我的注销按钮放置了以下代码

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

现在,当我的 URL 为 时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.

我该如何解决这个问题?

4

1 回答 1

0

">登出链接特别是部分:

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 

您正在使用相对路径,通过在 url 开头使用“/”使其成为绝对路径:

<a href="<c:url value="/j_spring_security_logout"/>">Log out</a>
于 2013-04-22T12:02:17.843 回答