【发布时间】:2020-03-31 15:29:03
【问题描述】:
我正在使用以下方法循环模型属性:
<li class="nav-item" th:each="item : ${navigation}"
sec:authorize='hasAnyAuthority("__${item.entitlements}__")'><a
class="nav-link" th:href="${item.url}" th:text="${item.display}"></a></li>
其中“item.entitlements”是一个包含一个元素的java List。在每个项目上(此时)。我还验证了该列表中每个项目的权利,并且在 spring 安全上下文中分配的权限是相同的。
我还尝试了以下方法:
${#authorization.expression('hasAnyAuthority(__${item.entitlements}__)')}
这可能吗?如果是这样,我错过了什么?我需要交换我的数据库以使用逗号分隔值的字符串吗?
我正在使用 spring boot 2.1.8.RELEASE 和以下 thymeleaf spring 安全依赖项:
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
最终版本为 3.0.4.RELEASE
【问题讨论】:
标签: spring-security thymeleaf spring-el