Spring Boot - thymeleaf模板引擎

博客介绍了Spring Boot开发中引入pom依赖实现热部署,修改静态资源、Java文件或配置文件后无需重启服务,节省时间。还提到创建HTML时需修改命名空间,因HTML不支持el表达式,建议查看Thymeleaf文档获取更多信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先引入pom依赖,第二个是spring boot热部署(每次修改完静态资源文件或java文件或者配置文件直接crtl+f9就可以直接编译,不需要来回重启服务,的确很节省时间,前期一点都不懂,浪费了不少时间)

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devttools</artifactId>
            <optional>true</optional>
        </dependency>

创建html时 修改命名空间 

<html xmlns:th="http://www.thymeleaf.org">

 html不支持el表达式所以直接${}取不到值;

<span th:text="${hello}" th:id="${hello}"></span>   th:赋值

不想写了,看看thymeleaf文档吧。哈哈哈哈哈哈,文档很详细,还有测试用例。

https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值