在我的春季安全应用程序中,我使用以下代码放置了我的注销按钮
<li><a href="<c:url value="j_spring_security_logout"/>">Log out</a></li>
现在,当我的网址为http://localhost:8080/servletname
时,注销工作正常。
即使它是http://localhost:8080/servletname/abc
,它也能正常工作。
但是当网址为http://localhost:8080/servletname/abc/xyz
时,当我点击退出按钮时,我会在页面重定向到http://localhost:8080/servletname/abc/j_spring_security_logout
时获得404页面。
我该如何解决这个问题?
答案 0 :(得分:0)
“&gt;退出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
你正在使用相对路径,在url:
的开头使用“/”使其成为绝对路径<a href="<c:url value="/j_spring_security_logout"/>">Log out</a>