Reputation: 35
I have something like this
<c:forEach var="authority" items="#{SPRING_SECURITY_CONTEXT.authentication.principal.authorities}">
<c:if test="${fn:contains( ${authority} , ROLE_ADMIN) }">
</c:if>
</c:forEach>
but it does not working, any ide how can I make this? Maybe there is some other way?
//Edited
Upvotes: 1
Views: 1918
Reputation: 1109645
There are 2 problems:
You should not nest EL expressions. Just reference the EL variable the usual way.
<c:if test="${fn:contains(authority, ROLE_ADMIN)}">
It's not clear from the question context if ROLE_ADMIN
is already in the EL scope. But you need to know that you cannot reference constants in EL. If it's for example an enum
, then it's good to know that they are just evaluated as String
. You need to quote it then.
<c:if test="${fn:contains(authority, 'ROLE_ADMIN')}">
Upvotes: 1
Reputation: 11274
You're missing a closing ")" in your if test:
<c:forEach var="authority" items="#{SPRING_SECURITY_CONTEXT.authentication.principal.authorities}">
<c:if test="${fn:contains( {$authority} , ROLE_ADMIN ) }">
</c:if>
</c:forEach>
Upvotes: 0