thymeleaf使用

thymeleaf使用

1.依赖

<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.1.6.RELEASE</version>
</parent>
<dependencies>
<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>
</dependencies>

2.配置前缀后缀

spring:
thymeleaf:
prefix: classpath:/templates/
suffix: .html
cache: false # 开发时禁用缓存

3.在resource下新建目录

  • 新写的html页面都放在此处
  • 记得新建的html文件加上名称空间
    <!DOCTYPE html>
    <html xmlns:th="http://www.thymeleaf.org">
    <head>
    <meta charset="UTF-8">
    <title>test1</title>
    </head>
    <body>
    <h1><span>test1.........</span></h1>
    </body>
    </html>

4.基础用法:

  • 修改标签文本值 th:text=""



posted @   锅巴编程  阅读(35)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示