且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取当前用户登录grails的id?

更新时间:2023-12-03 19:43:34

您可以使用springSecurityService来获取控制器中的一些用户信息: b
$ b

Well you can use the springSecurityService to get some user information in a controller:

    class MyController {
      def springSecurityService

      def myAction() {
        def principal = springSecurityService.principal
        String username = principal.username
        ...
      }
     }

或在gsp中

    <sec:loggedInUserInfo field="username" />

这是一个相当普遍的问题。

It is a pretty general question.