【发布时间】:2012-06-12 18:28:17
【问题描述】:
如果用户没有特定角色,我想阻止图像具有链接。例如
<sec:authorize ifNotGranted="ROLE_ACCOUNTS" ><img src="someimage.jpg"/></sec:authorize>
<sec:authorize ifAllGranted="ROLE_ACCOUNTS" ><a href="somelink.htm"><img src="someimage.jpg"/></a></sec:authorize>
然而,ifNotGranted 和 ifAllGranted 现在已被弃用,取而代之的是访问表达式。我可以看到 ifAllGranted 可以复制:
<sec:authorize access="hasRole('ROLE_ACCOUNTS')"><a href="somelink.htm"><img src="someimage.jpg"/></a></sec:authorize>
但是如何使用访问方法复制 ifNotGranted 呢?任何帮助将不胜感激。
【问题讨论】:
-
access="isFullyAuthenticated() 而不是 hasRole('ROLE_ACCOUNTS')"
-
@Ritesh 感谢
isFullyAuthenticated()对于另一个页面可能非常有用。但是,此处的页面访问权限仅对登录用户可用。not hasRole('ROLE_ACCOUNTS')成功了。
标签: jsp spring-security jsp-tags