怎样在Springboot中使用Thymeleaf实现动态网页

 时间:2026-02-14 15:04:16

1、使用本教程的前提是已经会springboot的基本入门操作,如果没有,请访问我的另一篇文章,非常简单。

2、下面我们开始thymeleaf开发,在main目录下创建resources/templates文件夹。

怎样在Springboot中使用Thymeleaf实现动态网页

3、修改TestController,注意标红的地方。

怎样在Springboot中使用Thymeleaf实现动态网页

4、添加thymeleaf依赖。

怎样在Springboot中使用Thymeleaf实现动态网页

5、在resources下创建application.yml文件,修改thymeleaf默认配置:不缓存页面,否则修改了页面后只能重启刷新页面。

注意:这个application.yml名称不能拼错。

怎样在Springboot中使用Thymeleaf实现动态网页

6、下面就是编写html了,在templates目录下创建index.html,内容如下,注意标红的地方。

怎样在Springboot中使用Thymeleaf实现动态网页

7、启动项目,访问http://localhost:8080即可访问首页。可以看到我们设置的参数已经展示出来了。

怎样在Springboot中使用Thymeleaf实现动态网页

8、以上便是在SpringBoot中展示动态网页,很简单吧。

  • 怎样使用VBA窗体中使用滚动文字?
  • Excel VBA如何获取数组索引的范围
  • ORACLE学习记:[1]oracle索引分类rebuild总结
  • 怎样使用VBA将英文转换为首字母大写?
  • 如何利用VBA代码自动插入一行数据
  • 热门搜索
    重庆交通大学怎么样 取款机怎么取钱 笔记本电脑开机黑屏怎么办 阳萎怎么办 怎么改照片格式 总是失眠怎么办 肌底液怎么用 ppt怎么自动播放 淘宝店铺名称怎么改 私生子怎么上户口