Search code examples
spring-mvcthymeleafshiro

Thymeleaf Shiro dialect custom expression


I am iterating through a list and setting a shiro:hasPermission attribute to each div like this

<div th:each="element : ${elements}" shiro:hasPermission="${element.permission}">
    <span th:text="${element.name}"></span>
</div>

where ${element.permission} is a permission string.

The div is not rendering even when the user has the permission. I have tried using th:attr like this:

<div th:each="element : ${elements}" th:attr="shiro:hasPermission=${element.permission}">
    <span th:text="${element.name}"></span>
</div> 

Still not working. I think the usage of shiro:hasPermission="${element.permission}" is not correct. How do I fix this?

I am using Spring MVC + Thymeleaf + Thymeleaf Shiro dialect.


Solution

  • I am the author of the thymeleaf-extras-shiro library.

    Version 1.2.2-SNAPSHOT supports expressions.