我使用带有百万富翁的HTML页面使用Spring安全性。我有一个问题是使用" sec:authorize"在这种情况下的财产:
<ul class="nav nav-tabs margin15-bottom">
<li th:each="criteriaGroup,iterGroups : ${aGroupList}"
th:class="${iterGroups.index == 0}? 'active'">
<a th:href="'#' + ${criteriaGroup.id}" data-toggle="tab"
th:text="${criteriaGroup.groupName}"></a>
</li>
</ul>
现在我想添加一个spring security属性:如果我有这个特殊条件,我需要一个授权(sec:authorize="hasRole('Criteria')"
),虽然我不会看到对应这个标准的标签:
<ul class="nav nav-tabs margin15-bottom">
<li th:each="aGroup,iterGroups : ${aGroupList}" th:class="${iterGroups.index == 0}? 'active'"
th:sec:authorize="$({criteriaGroup.id =='criteriaA'} || ${criteriaGroup.id =='criteriaB'}) ? 'hasRole('Criteria')'">
<a th:href="'#' + ${criteriaGroup.id}" data-toggle="tab"
th:text="${criteriaGroup.groupName}"></a>
</li>
</ul>
但是当我这样做时,我有以下错误:
org.thymeleaf.exceptions.TemplateProcessingException: Error processing template: dialect prefix "th" is set as non-lenient but attribute "th:sec:authorize" has not been removed during process
我该如何避免呢?
答案 0 :(得分:1)
删除th:在sec:authorize
前面Spring Security 3集成模块是Thymeleaf方言。可以找到更多信息here。
答案 1 :(得分:0)
也许您想要使用#authentication对象而不是sec方言。
来自文档:
<div th:text="${#authentication.name}">
The value of the "name" property of the authentication object should appear here.
</div>