调用j_spring_security_logout不起作用 [英] Call to j_spring_security_logout not working
问题描述
我正在尝试使用j_spring_security_logout设置应用程序的logut,但由于某种原因它无法正常工作,我不断收到404错误.
I'm trying to setup the logut of my application with j_spring_security_logout but for some reason it's not working, I keep getting a 404 error.
我正在这样调用函数:
<a href="<c:url value="/j_spring_security_logout"/>"><img border="0" id="logout" src="./img/logout.png" /></a>
我在WebContent/jsp/应用程序主页中,登录和注销页面在WebContent/login/中.
I have in WebContent/jsp/ my application main page, and the login and logout pages are in WebContent/login/.
我还检查了此其他帖子 Spring安全性退出问题,但是给出的解决方案对我不起作用.
I've also checked this other post Problem with Spring security's logout but the solution given there is not working for me.
在这里您可以看到我的web.xml
Here you can see my web.xml
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
这是我的spring-security.xml
And here my spring-security.xml
<http auto-config="true">
<intercept-url pattern="/*" access="ROLE_USER" />
<form-login login-page="/login/login.jsp"
authentication-failure-url="/login/errorLogin.jsp"/>
<logout logout-success-url="/" logout-url="/login/logout.jsp" />
</http>
<beans:bean id="myAuthenticationProvider"
class="myapp.web.authentication.WSAuthenticationProvider">
</beans:bean>
<authentication-manager>
<authentication-provider ref="myAuthenticationProvider"/>
</authentication-manager>
谢谢.
推荐答案
注销URL引用虚拟URL,您无需使用该名称的任何资源.您可以执行以下操作之一:
the logout-url refers to a virtual URL, you need not have any resource by that name. You can do either this:
<logout logout-success-url="/" logout-url="/j_spring_security_logout" />
和页面上的链接是这样的
and the link on your page like this
<c:url value="/j_spring_security_logout" var="logoutUrl" />
<a href="${logoutUrl}">Log Out</a>
或者这个:
<logout logout-success-url="/" logout-url="/logout" />
以及如下链接:
<c:url value="/logout" var="logoutUrl" />
<a href="${logoutUrl}">Log Out</a>
您正在混合使用这两种方式,这就是为什么您收到404错误的原因.
You were mixing both thats why you were getting 404 error.
这篇关于调用j_spring_security_logout不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!