如何在thymeleaf中组合sec:authorize和th:if?
<div class="form-group" sec:authorize="hasRole('ADMIN')" th:if="${myObjct.name!=null}"></div>
基本上,我需要结合sec:authorize =“hasRole('ADMIN')”和th:if =“$ {myObjct.name!= null}”,并且上面的代码无法正常工作,因为我期望如何结合这两者百里香的状况?
最佳答案
试一试:
<div class="form-group" th:if="${#authorization.expression('hasRole(''ADMIN'')')}"></div>
src:https://github.com/thymeleaf/thymeleaf-extras-springsecurity
关于spring-security - 如何在thymeleaf中组合sec:authorize和th:if,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36424393/