您可以注册logoutsuccesshandler并让它执行重定向:
public class RedirectingLogoutSuccessHandler implements LogoutSuccessHandler {
@Override
public void onLogoutSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
String basePath = request.getScheme() + "://" + request.getServerName()
+ (request.getServerPort() != 80 ? ":" + request.getServerPort() : "");
String otherContext = "/spring1";
response.sendRedirect(basePath + "/" + otherContext);
}
}
将其注册为bean并将安全配置指向它:
<logout
logout-url="/perform_logout"
success-handler-ref="redirectingLogoutSuccessHandler " />