thymeleaf(替代jsp)

本文介绍了Thymeleaf作为替代JSP的现代模板引擎的使用。主要内容包括Thymeleaf的基本语法,如th:each循环,以及如何使用th:fragment和th:include进行页面片段的包含。同时提到了`application.properties`配置文件的重要性,并提供了学习文档链接。
摘要由CSDN通过智能技术生成

thymeleaf

控制层
在这里插入图片描述
实体类
在这里插入图片描述
thymeleaf语法 加th注意蓝色指针的地方不能错 下面内容对应控制层
在这里插入图片描述

资源文件:application.properties 对应好
在这里插入图片描述
依赖:

<dependencies>
		<!-- spring mvc -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<!-- 解除html语法严紧问题 -->
		<dependency>
		   <groupId>nekohtml</groupId>
		   <artifactId>nekohtml</artifactId>
		   <version>1.9.6.2</version>
		</dependency>
 		<!-- 小辣椒 -->
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<version>1.16.18</version>
			<scope>provided</scope>
		</dependency>

重要
学习文档
https://blog.csdn.net/zrk1000/article/details/72667478
th:each循环
控制层
在这里插入图片描述
接口
在这里插入图片描述
实体类
在这里插入图片描述
资源文件
在这里插入图片描述
html
在这里插入图片描述
包含重要

要俩个html对应才能包含
<div th:fragment="myheader">
	新闻 视频 图片 军事 体育 NBA
</div><这里内容是一个html>


<这里内容也是一个html>
<div th:include="header :: myheader"></div>
all:移除所有<br/>
body:不移除自己,但移除他的子标签<br/>
tag: 只移除自己,不移除他的子标签<br/>
all-but-first:移除所有内容除第一个外<br/>
none:啥都不做<br/>

th:fragment=“myheader”
th:include=“header :: myheader”
上面红色代码俩个是对应的
include是包含header.html的内容
语法省略 .html

在这里插入图片描述
跳到对应地方

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值