spring-security - 如何在thymeleaf中组合sec:authorize和th:if

标签 spring-security thymeleaf

如何在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/

相关文章:

jquery - 自定义滚动事件

java - Thymeleaf 中的 Spring 安全表达式

grails - grails spring安全核心插件-使用用户名和电子邮件登录

java - Spring Security OAuth2授权流程

spring - 将 GWT 与 Spring Security 框架集成

java - 如何在@WebMvcTest测试中忽略@EnableWebSecurity注释的类

spring-boot - 如何生成包含一些自定义声明的 JWT 访问 token ?

java - Hibernate 和 Thymeleaf 无限递归

Thymeleaf:使用命名空间设置属性

java - 字段国际化错误