以编程方式在Spring Security中设置login-url

时间:2014-07-10 18:23:52

标签: java spring spring-security

是否存在与此XML配置等效的编程:

<logout logout-url="/logout"/>

虽然我可以像这样设置登录页面网址:

@Configuration
public static class ApplicationSecurity extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
            http
                 ...
                 .formLogin()
                 .loginPage("/login");
}

我找不到logout-url的等价物。

1 个答案:

答案 0 :(得分:2)

您需要and()

@Configuration
public static class ApplicationSecurity extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
            http
                 ...
                 .formLogin()
                 .loginPage("/login")
                 .and()
                   .logout().logoutUrl("/logout");
}