thymeleaf也是一模板技术,与freemarker类似,本文讲述springboot如何整合thymeleaf。
1、环境约束
- win10 64位操作系统
- idea2018.1.5
- maven-3.0.5
- jdk-8u162-windows-x64
2、前提约束
- 完成springboot创建web项目 https://www.jianshu.com/p/de979f53ad80
注意:笔者创建项目的时候约束的包前缀是net.wanho.springboot.thymeleaf,读者可以自行创建包名,只是要注意本文中的代码也要修改包名
3、修改pom.xml
在dependencies标签中加入以下依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
4、在net.wanho.springboot.thymeleaf包下面创建controller、entity子包
在entity下创建User.java
package net.wanho.springboot.thymeleaf.entity;
public class User {
private Intege