0

私の春のセキュリティアプリでは、ログアウトボタンを次のコードで配置しています

<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 に答える