SpringBoot + Thymeleaf +安全方言如何配置?

时间:2016-09-04 11:24:13

标签: spring spring-security thymeleaf

我真的很喜欢Spring Boot和Thymeleaf,我正在开发一个实现Spring Security的示例项目。而且我也想在我的项目中使用Thymeleaf Security Dialect。正如我所读到的,在Spring Boot的情况下,不需要为安全方言创建一个配置。 首先,我想要实现的是在视图中显示登录用户。 到目前为止我做了什么:

我添加了这个div来查看:

    <div sec:authentication="name">
        The value of the "name" property of the authentication object should appear here.
    </div>

并为pom.xml添加了依赖性:

<!-- https://mvnrepository.com/artifact/org.thymeleaf.extras/thymeleaf-extras-springsecurity4 -->
<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity4</artifactId>
    <version>3.0.0.RELEASE</version>
</dependency>

如果有人有任何想法,请告诉我。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题,或者我找到了解决方案。 问题是我使用了3.0.0.RELEASE thymeleaf-extras-springsecurity4版本。使用2.1.2.RELEASE可以正常工作。

相关问题