Spring boot 升级spring&;百里香叶打破了我的记忆
我正在将我的Spring Boot应用程序从1.3.5升级到1.4.4(最终升级为1.5.x),我注意到我的Thymeleaf菜单项现在坏了。 以下是我对它们的理解:Spring boot 升级spring&;百里香叶打破了我的记忆,spring-boot,thymeleaf,Spring Boot,Thymeleaf,我正在将我的Spring Boot应用程序从1.3.5升级到1.4.4(最终升级为1.5.x),我注意到我的Thymeleaf菜单项现在坏了。 以下是我对它们的理解: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"> ...
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
...
<ul class="nav pull-right">
<li sec:authorize="${!isAuthenticated()}">
<div>
<span></span>
</div>
</li>
<li sec:authorize="${isAuthenticated()}">
<span th:inline="text">Logged in as [[${#httpServletRequest.remoteUser}]</span>
</li>
</ul>
到
但是,授权元素的显示方式就好像绕过了安全性一样。是否有什么改变了sec:authorize的工作方式?我查看了Thymeleaf文档,但没有看到它。我知道被验证的用户具有适当的角色,并且已被验证
更新:
为了实现其价值,我尝试将引导和jquery版本更新为:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"/>
<script src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
但这仍然不能解决显示错误项目的问题。尝试sec:authorize=“isAuthenticated()”
而不是sec:authorize=“${isAuthenticated()}”
Spring Boot 1.x使用thymeleaf 2,SB 2.x使用thymeleaf 3
如果要将thymeleaf 3与SB 1.x一起使用,则需要进行其他配置:是否可以尝试改用此声明<代码>xmlns:sec=”http://www.thymeleaf.org/extras/spring-security“这似乎没有什么区别-页面加载时会显示所有项目。是否确实不希望使用
isAnonymous()
和isAuthenticated()
?不确定这个具体问题,但这似乎对我有效(Spring4非启动),我尝试将isAuthenticated()转换为isAnonymous(),但没有任何区别。这一直有效,直到我将Spring 1.3.5升级到1.4.4,这意味着我还必须更改我的Thymeleaf、gradle依赖项,etcI最终这样做:sec:authorize=“${isAuthenticated()}”我没有使用Thymeleaf:3.0.3.RELEASE和Thymeleaf-spring4:3.0.3.RELEASE我无法获得sec:authorize=“isAuthenticated()”使用这个新版本。
compile group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: '1.4.4.RELEASE'
compile group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity4', version: '3.0.2.RELEASE'
compile group: 'org.thymeleaf', name: 'thymeleaf-spring4', version: '3.0.9.RELEASE'
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"/>
<script src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4"