使用视图中的spring security访问当前登录的用户username

1 grails spring-security gsp textfield

如何在gsp视图中使用springSecurity访问当前登录的用户名,或者更具体地说,在文本字段中使用此值?

以下解决方案不起作用:

值= "$ {sec.loggedInUserInfo(字段: '用户名')}"

Mea*_*eam 6

以下几行在我的测试中都能正常工作.

<input name="username" type="text" value="${sec.username()}" />
<input name="username" type="text" value="${sec.loggedInUserInfo(field: 'username')}" />
Run Code Online (Sandbox Code Playgroud)

您可能来自其他地方的错误.你可以只在GSP中使用那个输入标签进行测试吗?