1.前端页面写法
<a href="javascript:;" onclick="logoutBackground()">退出</a>
2.js
/**
* 退出后台
*/
function logoutBackground() {
$.get("/admin/logout", function (msg) {
if (msg === "true") {
window.location.href = "/userlogin";//自定义静态页面路径
} else {
alert("退出异常!");
}
});
}
3.security配置
//登出操作
.logout().logoutUrl("/admin/logout")
.logoutSuccessHandler((request, response, authentication) -> {
PrintWriter writer = response.getWriter();
writer.write("true");
writer.close();
}).permitAll()