【发布时间】:2018-04-23 19:58:55
【问题描述】:
我想禁用特定链接但保留其文本,使其看起来像是被禁用。我正在尝试在锚标记内放置具有特定条件的 th:remove 。我在 ThymeLeaf 教程页面上找到了这个:
<a href="/something" th:remove="${condition}? tag">Link text not to be removed</a>
基于此,我正在尝试这样做:
<li>
<a th:href="@{/config/mod/}"
th:remove="${#authorization.expression('hasRole(''VIEW_MODULE_STATUS'')')}? tag">
<i class="fa fa-gear"></i> [[#{webadmin.view.config.module.title.short}]]
</a>
</li>
其中 VIEW_MODULE_STATUS 是角色。这种情况似乎不起作用,我不明白为什么。
仅供参考:我在锚标记中使用了sec:authorize="hasRole('VIEW_MODULE_STATUS')",它工作正常。我想避免这种方法,因为它完全删除了文本和链接。有没有其他方法可以禁用链接并使用 ThymeLeaf 保留文本?
(我使用的是百里香3.0)
【问题讨论】:
标签: java spring-security thymeleaf spring-el