2014-04-02 28 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