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" />

相关文章

这篇文章主要介绍了spring的事务传播属性REQUIRED_NESTED的原...
今天小编给大家分享的是一文解析spring中事务的传播机制,相...
这篇文章主要介绍了SpringCloudAlibaba和SpringCloud有什么区...
本篇文章和大家了解一下SpringCloud整合XXL-Job的几个步骤。...
本篇文章和大家了解一下Spring延迟初始化会遇到什么问题。有...
这篇文章主要介绍了怎么使用Spring提供的不同缓存注解实现缓...