1.在springBootStudio项目中添加Module。
2.选择Spring Initializr,点击next。
3.Group填写com.chanchifeng,Artifact填写thymeleaf。
4.勾选SQL中的Web和Thymeleaf,点击next。
5.Content_root和Module file location选择springBootStudio项目路径。
6.在项目中创建一个controller包,在其下创建PageController的类,代码如下:
1 |
|
7.在项目中的templates创建一个home的html页面,代码如下:
1 |
|
8.运行ThymeleafApplication.main,在浏览器中访问http://localhost:8080/home,即可实现一个简单的thymeleaf的Demo,更多的使用方法请参考官方文档(https://www.thymeleaf.org/)。