<!-- Display logged-in username -->
<strong sec:authentication="name">anonymous</strong>
<!-- Display user's authorities/roles -->
<span sec:authentication="principal.authorities">[]</span>
This block is ONLY visible to users with the ADMIN role.
Login as admin / password to see this.
| ID | Name | Score | Grade |
|---|---|---|---|
This block is visible to all logged-in users (USER and ADMIN roles).
You are not logged in. Login here to see more content.
<!-- Show only to ADMIN -->
<div sec:authorize="hasRole('ADMIN')">Admin content</div>
<!-- Show to any authenticated user -->
<div sec:authorize="isAuthenticated()">User content</div>
<!-- Show only to guests -->
<div sec:authorize="!isAuthenticated()">Guest content</div>
<!-- Show to USER or ADMIN -->
<div sec:authorize="hasAnyRole('USER','ADMIN')">Content</div>
<!-- Using Spring Security expression -->
<div sec:authorize="hasRole('ADMIN') and isFullyAuthenticated()">
Strictly admin, no remember-me
</div>