繁体   English   中英

使用Spring Security Core插件在Grails中登录后如何重定向到页面

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM