Reputation: 1460
I am trying to use the user id, stored as a principal property inside the Spring Security Authentication token in a HTML tag such as :
<a href="/users/${id}">Profile page</a>
I am only aware of two alternatives to use the id from the Spring Security principal object:
Use the dedicated taglib's authentication tag (wouldn't work here, as JSP doesn't allow nested tags as far as I know).
Use a scriptlet, which I would really like to avoid. If anybody is aware of a an elegant one doing the job, I would be interested anyway.
I would like to be able to use something along the lines of EL.
Upvotes: 0
Views: 617
Reputation: 10632
You can use JSTL c:set
for this:
<c:set var="id"><security:authentication property="username" /></c:set>
<a href="/users/${id}">Profile page</a>
Upvotes: 2