如何从具有 Spring 安全性的控制器注销
How to logout from a controller with Spring Security
是否有我可以在控制器中使用的 Spring 安全注销方法?或者有没有办法通过清除缓存和刷新来注销?
Grails 控制器有一个 request
object available in them that is an instance of HttpServletRequest
. You can use this to log the current user out by calling the logout()
方法。
class TestController {
def logMeOut() {
request.logout() // Logout current user
redirect(controller: 'home', action: 'index') // Redirect to the home page
}
}
Spring安全加一点more information on the logout method.
是否有我可以在控制器中使用的 Spring 安全注销方法?或者有没有办法通过清除缓存和刷新来注销?
Grails 控制器有一个 request
object available in them that is an instance of HttpServletRequest
. You can use this to log the current user out by calling the logout()
方法。
class TestController {
def logMeOut() {
request.logout() // Logout current user
redirect(controller: 'home', action: 'index') // Redirect to the home page
}
}
Spring安全加一点more information on the logout method.