Springsecurity 整合 Thmeleaf 页面sec:xxxxxx不显示问题
1.—Spinrgboot版本问题
需要把SpringBoot 的版本调整到 2.1.X 以下
2.0.9即可 不过登录页非常1老旧
据说一般 2.0.7 最稳定
注:大部分问题基本出在这里
2.2.x 有几个版本据说好像没有毛病,但具体不清楚,有的可以告知笔者一下,
查到的有2.2.4/2.2.6 具体不清楚
2.—SpringSurity版本问题
<!--springsecurity4 要指定3.0以上版本,否则权限标签可能无法工作-->
即:<version>3.0.4.RELEASE</version>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<version>3.0.4.RELEASE</version>
<!--这里一定要写这个版本,即使dependencies显示的有-->
</dependency>
版本修改-》
springsecurity4 换成 springsecurity5
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
<version>3.0.4.RELEASE</version>
<!--这里一定要写这个版本,即使dependencies显示的有-->
</dependency>
并改变页面<html> 标签中对应的命名空间
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
也是4改成5
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
很多答案存在这个问题所以记载一下,但
个人觉得这个关系比较模糊,作用不是很大
3.—纯粹是命名空间问题
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
注意:有https的改为http
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
github:英文解说原件
Namespace
The namespace for all versions of this dialect is
http://www.thymeleaf.org/extras/spring-security.
<html xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
Getting the namespace incorrect won't impact processing of your template.
It might however impact your IDE when it comes to things
like suggestions/auto-completion in your templates.
翻译:--》
命名空间
该方言所有版本的名称空间为http://www.thymeleaf.org/extras/spring-security。
< html xmlns:sec =“ http://www.thymeleaf.org/extras/spring-security ” >
弄错名称空间不会影响模板的处理。但是,涉及模板中的建议/自动完成等问题时,它可能会影响您的IDE。
4.—thmeleaf版本问题
thymeleaf-extras-springsecurity版本3.0.4.RELEASE
-适用于Thymeleaf 3.0(需要Thymeleaf 3.0.10+)
这里的version自己查一下,改成3.x.x几
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
</dependency>
5.–其他
https://blog.csdn.net/c_learner_/article/details/107228678
可参考官方文档:
点击查看github官方说明:
https://github.com/thymeleaf/thymeleaf-extras-springsecurity
点击查看thymeleaf官方说明:
https://www.thymeleaf.org/doc/articles/springsecurity.html