另一方面,Spring Security的默认终止处理逻辑会禁用当前会话,清除与当前用户相关的remember-me记录,并将当前安全内容重定向到登录页二. Spring Security注销配置如果不使用sping,则会给出一系列默认值
logoutUrl :注销对应的地址logoutSuccessHandler :注销成功后,您可以在此处处理自己的注销逻辑deleteCookies。 注销成功后,删除指定的cookieprotectedvoidconfigure (httpsecurityhttp ) throwsexception(http.csrf ).disable.ant matched logout )、'/signOut ' ).permitall(.logout ).logoutsuccesshandler ).mylogoutsucccesshandler } @ slf4j @ componentpublicclassmylogoutsuccesshandlerimplementslogoutsuccesshandler { @ overridepublicvoidonlogoutsuccccess (hovess ) s t,HttpServletResponse response,authenticationauthentication (throwsioexception,servletexception ) log.info )退出成功) response.sendredirect ()/signout ); }三)注销页面的路径与视图的简单映射
@ configurationpublicclasswebmvcconfigurationimplementswebmvcconfigurer { @ overridepublicvoidaddviewcontrollers (view controlol ) registry.addviewcontroller ((/signout ) ).setviewname ) (sign out ); registry.addviewcontroller ((/index ) ).setviewname ) (index ); }} signOut.html注销页面
! doctypehtmlhtmllang=' en ' xmlns=' http://www.w3.org/1999/XHTML ' xmlns 3360 th=' http://www.thyme leaf.org ' head