In this recipe, you'll learn how to add a URL /logout
to let the user log out.
In the SecurityConfig
class, in the configure()
method, call the logout()
method and the logoutRequestMatcher()
method to declare a logout URL:
protected void configure(HttpSecurity http) throws Exception { ... AntPathRequestMatcher pathRequestMatcher = new AntPathRequestMatcher("/logout"); http.logout().logoutRequestMatcher(pathRequestMatcher); }