![](/img/trans.png)
[英]Grails spring security - how to redirect to the same page after login?
[英]How to redirect to a page after login in Grails using spring security core plugin
我正在使用Grails 2.1.1和spring-security-core 1.2.3.7。 当我运行应用程序时,显示登录页面是因为我已经从URL映射显示了登录页面。 但是,当我登录时,它不会重定向到主页。 它停留在登录页面上。
这是我的网址映射:
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(view:"/login/auth")
"500"(view:'/error')
}
将所需的controller
/ action
添加到您的网址映射中:
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"/"(controller:"yourcontroller", action: "youraction)
"500"(view:'/error')
}
如果以任何方式确保您在youraction
中的yourcontroller
是安全的,则Spring Security将管理重定向到auth
页面并在成功通过身份验证后返回到youraction
的重定向。
您可以像这样在config.groovy
文件中的默认成功URL上输入一个条目
grails.plugins.springsecurity.successHandler.defaultTargetUrl = 'controllerName/actionName'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.