springBoot加入thymeleaf模板的方式

网友投稿 234 2022-11-17


springBoot加入thymeleaf模板的方式

1.新建springBoot项目

在前面有两种方式

2.加入thymeleaf模板引擎

SpringBoot推荐使用thymeleaf模板引擎

语法简单,功能更强大

要想引入thymeleaf,只需要在pom,xml文件中加入如下依赖就可以了

org.springframework.boot

spring-boot-starter-thymeleaf

3.在controller中定义跳转的页面

会自动去templafxKiates文件夹下去找index.html

4.运行,然后访问项目

输入http://localhost:8080/testThymeleaf即可访问index.html

5.在html页面中加入thymeleaf模板标签所需的命名空间

afxKi

欢迎来到测试thymeleaf界面

6.将controller数据通过thymeleaf标签传到前端界面

把数据放在controller的map中

前端通过标签取出数据

显示效果

6.thymeleaf标签语法

官方文档

https://thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.pdf

thymeleaf中文

https://raledong.gitbooks.io/using-thymeleaf/content/Chapter1/section1.1.html

常用标签介绍


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:java9开始——接口中可以定义private私有方法
下一篇:maven加入spring框架的详细教程
相关文章

 发表评论

暂时没有评论,来抢沙发吧~