Reputation: 4043
I'm writing an update or change user data form in Grails. This is a part of my form, where user can change his old login:
<g:form class="form-signin" controller="VisitorSpace">
<label for="login" class="sr-only">Логин</label>
<g:textField id="login" class="form-control" name="login" placeholder="Логин" value="${springSecurityService.principal.username}" required="" autofocus=""/>
...
</g:form>
Old user data must be shown before update. I use for it: ${springSecurityService.principal.username}
But when I run this page I get such error:
Error 500: Internal Server Error
URI:/restorator/visitorSpace/editPrivateDataClass:java.lang.NullPointerExceptionMessage:Cannot get property 'principal' on null object
Upvotes: 0
Views: 1005
Reputation: 122364
For that to work you would have had to have passed the springSecurityService
to the GSP via its model. You can use applicationContext.springSecurityService
to extract it from the context if you don't want to pass it in, or use the taglib instead of the service.
Upvotes: 1