我正在开发实现 spring 安全性的简单项目。当我尝试使用Spring和Thymeleaf 的注销链接时,问题就出现了。
1.pom.xml
<!--Spring Boot Dependencies - Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Dependencies Spring Security-->
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>2.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
导航栏.html
<ul class="nav navbar-nav navbar-right">
<!--<li><a th:href="@{/login}" th:text="#{navbar.login.text}"></a></li>-->
<li th:if="${#authorization.expression('isAuthenticated()')}">
<a th:href="@{/login}" th:text="#{navbar.login.text}"/>
</li>
<li th:if="${#authorization.expression('isAuthenticated()')}">
<form id="f" th:action="@{/logout}" method="post" role="form" class="navbar-form">
<button type="submit" th:text="#{navbar.logout.text}" class="btn btn-primary"/>
</form>
</li>
</ul>
错误截图:
心有法竹
相关分类