springboot2.x集成thymeleaf

 时间:2026-02-24 06:04:05

1、使用eclipse的sts工具,创建springboot项目并勾选web依赖和thymeleaf依赖

springboot2.x集成thymeleaf

springboot2.x集成thymeleaf

springboot2.x集成thymeleaf

2、eclipse在创建springboot2.1.6项目时,pom文件会报错。需要调整pom文件中的依赖。添加标出的东西后,重新更新项目即可

springboot2.x集成thymeleaf

springboot2.x集成thymeleaf

3、编写控制器controller

springboot2.x集成thymeleaf

4、springmvc不再赘述。上一步中标出的返回值路径,默认在项目的templates文件夹下

springboot2.x集成thymeleaf

5、编写前端页面。注意,一定要写入thymeleaf的声明

springboot2.x集成thymeleaf

6、thymeleaf默认是开启缓存的,所以有的时候当我们改了页面以后也不会立即展示新改的,所以需要关闭缓存

springboot2.x集成thymeleaf

7、启动项目,访问页面看看.当 name和age有值的时候,会覆盖掉那两个未知。具体语法可以查看thymeleaf官网

springboot2.x集成thymeleaf

  • 怎样在Springboot中使用Thymeleaf实现动态网页
  • springboot2.x搭建springcloud
  • 集成灶是什么?集成灶好吗?如何挑选?
  • Spring boot如何使用模板引擎thymeleaf
  • springboot2.x的静态资源和拦截器处理
  • 热门搜索
    羽绒服洗了以后一坨一坨的怎么办 紫草油的做法 海虾的做法 谏怎么读 我的世界末地传送门怎么做 干锅的做法 醋溜白菜的家常做法 炒粉的做法 咸菜的做法 小馄饨的做法