[英]How to logout from a controller with Spring Security
Is there a logout method for Spring Security that I can use in a controller?我可以在 controller 中使用 Spring 安全性的注销方法吗? Or is there a way to logout by clearing the cache and refreshing?
或者有没有办法通过清除缓存和刷新来注销?
Grails controllers have a request
object available in them that is an instance of HttpServletRequest
. Grails 控制器有一个
request
object 可用,它是HttpServletRequest
的一个实例。 You can use this to log the current user out by calling the logout()
method on it.您可以使用它通过调用
logout()
方法来注销当前用户。
class TestController {
def logMeOut() {
request.logout() // Logout current user
redirect(controller: 'home', action: 'index') // Redirect to the home page
}
}
Spring Security adds a little more information on the logout method . Spring 安全性添加了有关注销方法的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.