小编don*_*gPB的帖子

弹出注销时出错404

我正在尝试使用spring security v.4为我的应用添加登录功能.登录工作正常,但当我尝试注销时出现错误404.Spring Security参考说默认注销URL是/ logout.我的应用程序部署在/ app URL下,我尝试按照URL的localhost:8080/app/logout和localhost:8080/app/json/logout.我在堆栈上发现了一些类似的问题,但它们是关于使用CSRF保护并且我没有使用它的情况.这是我的web.xml文件的一部分

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/json-servlet.xml,
        /WEB-INF/applicationContext.xml</param-value>
</context-param>

<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>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>json</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>json</servlet-name>
    <url-pattern>/json/*</url-pattern>
</servlet-mapping>
Run Code Online (Sandbox Code Playgroud)

和我的json-servlet.xml在哪里是spring安全配置:

    <context:component-scan base-package="test" />
<mvc:annotation-driven />

<security:http>
    <security:intercept-url pattern="/**" access="hasRole('USER')" />
    <security:form-login />
    <security:logout />
</security:http>

<security:authentication-manager>
    <security:authentication-provider>
        <security:user-service>
            <security:user name="test" password="1" authorities="ROLE_USER, ROLE_ADMIN" />
        </security:user-service>
    </security:authentication-provider>
</security:authentication-manager>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

spring spring-security logout http-status-code-404

4
推荐指数
1
解决办法
5083
查看次数