LogoutSuccessHandler doesn't work for Spring Security -


i cant use spring security logoutsuccesshandler in current project. previously, worker not used.

here class:

import org.springframework.security.core.authentication; import org.springframework.security.web.authentication.logout.simpleurllogoutsuccesshandler; import org.springframework.stereotype.component;  import javax.servlet.servletexception; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception;  @component("customlogoutsuccesshandler") //or implements logoutsuccesshandler public class customlogoutsuccesshandler extends simpleurllogoutsuccesshandler {     @override     public void onlogoutsuccess(httpservletrequest httpservletrequest, httpservletresponse httpservletresponse, authentication authentication) throws ioexception, servletexception {         system.err.println("logout handler here");     } } 

and here xml config

<security:http auto-config="false" >                           <security:logout logout-url="/logout" success-handler-ref="customlogoutsuccesshandler"/>            <security:form-login login-page="/login" default-target-url="/"/>            <security:csrf/> </security:http> 

whats wrong code? onlogoutsuccess method never run if logged out:

@requestmapping(value = "/logout") public string logout(){     securitycontextholder.clearcontext();     return "redirect:/"; } 

why?

you not doing in logout() method, easier remove - /logout default logout url in spring security , should serve (clearing context)for you. breaking filter chain using redirect:/


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -