2014-04-02 107 views
3

我使用春節安全與HTML頁面使用百里香。我必須用「秒:授權」問題屬性在這種情況下:春季安全使用「如果」情況下的百里香

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

現在我要像添加彈簧安全特性:如果我有這個特別的標準,我需要一個授權(SEC:授權=「hasRole(‘標準’)」),雖然我不會看到對應於這個標準的標籤:

<ul class="nav nav-tabs margin15-bottom"> 
         <li th:each="aGroup,iterGroups : ${aGroupList}" 
          th:sec:authorize="$({criteriaGroup.id =='criteriaA'} || ${criteriaGroup.id =='criteriaB'}) ? 'hasRole('Criteria')'" 
          th:class="${iterGroups.index == 0}? 'active'"><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 

哪有我避開它?

回答

1

刪除日:以秒爲單位的前:授權

春季安全3集成模塊是一個Thymeleaf方言。更多信息可以在here找到。

0

也許你想使用#authentication對象而不是sec方言。

從文檔:

<div th:text="${#authentication.name}"> 
    The value of the "name" property of the authentication object should appear here. 
</div> 
+0

使用#authentication身份表達似乎並不在默認情況檢查空。 – aalmero