微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Java – JSTL标签中的Spring安全开关案例

有没有办法转换窗体的jsp代码

ecurity:authorize access="hasRole('ROLE_USER')">You're an userecurity:authorize>
ecurity:authorize access="hasRole('ROLE_ADMIN')">You're an adminecurity:authorize>
ecurity:authorize access="hasRole('ROLE_SADMIN')">You're a superadminecurity:authorize>

到另一种形式,类似于以下(不起作用)?

更确切地说,有没有办法用JSTL标签替换这个Spring Security taglib功能

最佳答案
您可以使用< security:authorize />的var属性.标签将创建:

A page scoped variable into which the boolean result of the tag
evaluation will be written,allowing the same condition to be reused
subsequently in the page without re-evaluation.

ecurity:authorize access="hasRole('ROLE_USER')" var="isUser" />
ecurity:authorize access="hasRole('ROLE_ADMIN')" var="isAdmin" />
ecurity:authorize access="hasRole('ROLE_SADMIN')" var="isSuperUser" />

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐