Java 在SimpleRoulGoutSuccessHandle上未调用onLogoutSuccess

Java 在SimpleRoulGoutSuccessHandle上未调用onLogoutSuccess,java,spring-boot,spring-security,Java,Spring Boot,Spring Security,这是我的自定义处理程序:CustomLogoutSuccessHandler.java @Configuration @EnableWebSecurity public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired private DataSource dataSource; // get by Spring @Override public void

这是我的自定义处理程序:CustomLogoutSuccessHandler.java

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Autowired
    private DataSource dataSource; // get by Spring

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
            // Here, you are making the public directory on the classpath root available without authentication (e..g. for css files)
            .antMatchers("/public/**", "/registration.html").permitAll()
            .anyRequest().authenticated()
            .and()
            .formLogin()
            .loginPage("/login.html")
            .successHandler((request, response, authentication) -> new DefaultRedirectStrategy().sendRedirect(request, response, "/welcome"))
            .failureUrl("/login-error.html")
            .permitAll()
            .and()
            .logout()
            .logoutSuccessHandler(new CustomLogoutSuccessHandler())
            .permitAll();
    }
}
在我的模板(
users.html
)中,我添加了如下链接:

public class CustomLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler {
    private static Logger logger = LogManager.getLogger(CustomLogoutSuccessHandler.class);

    @Override
    public void onLogoutSuccess(
            HttpServletRequest request,
            HttpServletResponse response,
            Authentication authentication)
            throws IOException, ServletException {
        logger.info("onLogoutSuccess:");
        response.sendRedirect(request.getContextPath() + "/login.html");
    }
}

但是当单击注销链接时,方法
onLogoutSuccess
不会调用我的自定义处理程序类

为什么?

退房退房
<p align="center"><a th:href="@{/logout.html}">Logout</a></p>