thymeleaf使用小记

Posted falcon-fei

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thymeleaf使用小记相关的知识,希望对你有一定的参考价值。

记录thymeleaf使用种遇到的一些问题,备忘。

 

前台页面显示当前登陆用户

使用thymeleaf+springsecurity,想要显示当前登陆用户,有专门的标签。使用顺序如下

1、  引入jar包 (需要注意的是要同thymeleaf版本相对应 )
2、  maven坐标如下
<dependency>

    <groupId>org.thymeleaf.extras</groupId>

    <artifactId>thymeleaf-extras-springsecurity4</artifactId>

    <version>2.1.3.RELEASE</version>

</dependency>

 springboot打包后 找不到html,在idea里面运行正常

 原因是:spinrgboot没有webapp目录,在resource的几个static等文件夹里面,用thymeleaf的话 controller里面,对于模板路径的指定不能带 /

技术分享图片

 


 

以上是关于thymeleaf使用小记的主要内容,如果未能解决你的问题,请参考以下文章

Spring boot:thymeleaf 没有正确渲染片段

Thymeleaf引用片段传入参数

Spring MVC 3.2 Thymeleaf Ajax 片段

ThymeLeaf 片段在错误 th:if 上执行

Thymeleaf 模板 - 有没有办法装饰模板而不是包含模板片段?

Thymeleaf,片段和默认参数