java - spring security - 动态更改注销成功url

标签 java spring-mvc spring-security

我正在开发一个java spring mvc项目。这是我的 securityConfig 类的一部分:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            ....
            .logoutSuccessUrl("/loginForm")
            ...
}

当用户注销时,spring将他重定向到loginForm页面。但是,我想动态更改此网址。事实上,我想根据某些条件将用户重定向到不同的页面。我怎样才能做到这一点?

最佳答案

参见LogoutSuccessHandler :

Strategy that is called after a successful logout by the LogoutFilter, to handle redirection or forwarding to the appropriate destination.

有关 Java 配置,请参阅 LogoutConfigurer#logoutSuccessHandler .

您修改后的源代码:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .logout().logoutSuccessHandler(myLogoutSuccessHandler);
}

关于java - spring security - 动态更改注销成功url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33564991/

相关文章:

spring - spring Security 中的 UsernamePasswordAuthenticationFilter 没有被调用

security - Spring - 安全 : how are login username and password bound to the authentication-provider?

java - 从 Java SDK 获取 Azure VM 价格

javascript - Hibernate,适用于 Windows,但不适用于 Linux。它复制表格并弄乱一些表格的名称

spring - java.lang.NoClassDefFoundError 在谷歌应用引擎上使用 spring security

java - 如何让网站上线? (从将它作为 Netbeans 中的 Spring MVC 项目的角度来看)

spring - 什么是 <spring :hasBindErrors>?

java - 如何使用 Twitter Fabric Android 获取关注者列表?

java - 重用 StringBuffer

java - Eclipse Neon.2 : Unable to add Gradle Buildship 中的 Spring 启动器插件问题