25

How would I write following condition using spring security taglib?

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authorize access="not of hasRole('ROLE_ADMIN')">
   <div> show these for only non admins </div>
</sec:authorize>
Dileepa
  • 1,019
  • 1
  • 15
  • 40

1 Answers1

54
<sec:authorize access="!hasRole('ROLE_ADMIN')">
   <div> show these for only non admins </div>
</sec:authorize>
Frederic Close
  • 9,389
  • 6
  • 56
  • 67
  • Does not working on Controller/Mapped level: @PreAuthorize("!hasRole('ROLE_ADMIN')"). Any idea? – Wooff Apr 29 '21 at 11:04