Thymeleafs

时间:2018-05-26 20:41:05

标签: spring-mvc spring-boot spring-security thymeleaf

我正在使用带有Thymeleafes和Spring安全性的Spring Boot。但是,视图文件中无法识别Spring安全标记。它们被跳过,并且显示经过身份验证的块和任何块中的内容。我尝试使用普通弹簧安全标签和百日咳标签:

<div sec:authorize="isAuthenticated()">
  authenticated
</div>
<div sec:authorize="isAnonymous()">
  anonymous
</div>
<sec:authorize access="isAuthenticated()">
    authenticated
</sec:authorize>
<sec:authorize access="isAnonymous()">
    anonymous
</sec:authorize>

输出结果为:

authenticated 
anonymous 
authenticated 
anonymous

可能是什么问题?我需要任何配置吗?这是我的pom文件内容。在此先感谢您的帮助

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
<dependency>
    <groupId>org.thymeleaf.extras</groupId>
    <artifactId>thymeleaf-extras-springsecurity4</artifactId>
    <version>3.0.2.RELEASE</version>
</dependency>   
    </dependencies>

0 个答案:

没有答案