如何获取当前用户登录grails的id? [英] How to get id of the current user logged in grails?

查看:123
本文介绍了如何获取当前用户登录grails的id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示登录用户的信息,如注册时给出的详细信息等...如何操作?正如我新的Grails PLZ的帮助! iam使用Spring安全性插件

I want to display the info about the user logged in like his details etc given during sign up ...how to do it ?? As iam new to grails plz help! iam using Spring security plugin

推荐答案

您可以使用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.

这篇关于如何获取当前用户登录grails的id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆