How to attemp sec:loggedInUserInfo into a variable in gsp

Mr Zoomzoom picture Mr Zoomzoom · May 26, 2011 · Viewed 7.7k times · Source

I want to get value of sec:loggedInUserInfo and attempt into a variable named user.

My code looks like this:

<sec:loggedInUserInfo field="username" /> 

<%
  def user = *value of field loggedInUserInfo *
%>

Is it possible for doing that?

Answer

Chris picture Chris · May 26, 2011

This is simpler and works fine for me:

<g:set var="user" value="${sec.username()}" />