I would like to prevent an image having a link if a user does NOT have a certain role. e.g.
In case if you have many files to update, I recommend use the regular express to search and replace
find
<sec:authorize\s+ifAnyGranted="([^"]+)"
replace with
<sec:authorize access="hasAnyRole('$1')"
and search
<sec:authorize\s+ifNotGranted="([^"]+)"
replace with
<sec:authorize access="!hasAnyRole('$1')"
Hope this can save you time
SpEL expression can be negated with !
operator:
<sec:authorize access="!hasRole('ROLE_ACCOUNTS')">...</sec:authorize>
See also: