社区
付强的课程社区_NO_2
SpringBoot系统课程
帖子详情
thymeleaf循环判断
bakerfu
2023-01-12 22:39:41
课时名称
课时知识点
thymeleaf循环判断
thymeleaf循环判断
...全文
145
回复
打赏
收藏
thymeleaf循环判断
课时名称课时知识点thymeleaf循环判断thymeleaf循环判断
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
SpringBoot2整合
thymeleaf
3及
thymeleaf
3语法.md
## springboot整合
thymeleaf
### 1. 导入起步依赖 ```xml org.springframework.boot spring-boot-starter-
thymeleaf
``` ### 2. 更改引入版本 ```xml 3.0.2.RELEASE 2.1.1 ``` > 1. springboot自带的
thymeleaf
依赖为2.1.3版本,使用
thymeleaf
-layout-dialect版本为2以下版本。 > 2. 使用3或3以上的
thymeleaf
时,需要
thymeleaf
-layout-dialect的版本为2或以上。 > 3. 锁定
thymeleaf
版本时不能使用
thymeleaf
.version标签,会和springboot内部的依赖标签冲突。应当使用springboot-
thymeleaf
.version标签来锁定版本。 ### 3. 配置文件配置 ```properties spring.
thymeleaf
.prefix=classpath:/templates/ spring.
thymeleaf
.check-template-location=true spring.
thymeleaf
.suffix=.html spring.
thymeleaf
.encoding=UTF-8 spring.
thymeleaf
.content-type=text/html spring.
thymeleaf
.mode=HTML spring.
thymeleaf
.cache=false ``` > spring.
thymeleaf
.cache为缓存,需要热部署时,需要设置为false ## 语法 ### 1. 替换标签体内容 ```html 显示欢迎 显示欢迎 ``` ### 2. 替换属性 ```html 显示欢迎 ``` ### 3. 在表达式中访问属性域 ```html 访问属性域 访问请求域 方式一 访问请求域 方式二 访问Session域 访Session域 方式一 访问Application域 方式一 ``` ### 4. 解析url地址 ```html 解析URL地址,获取ContextPath的值 @{}是把ContextPath的值附加到指定的地址前 @{}是把ContextPath的值附加到指定的地址前 ``` ### 5. 直接执行表达式 ```html 直接执行表达式 无转义效果 : [[${attrRequestScope}]] 有转义效果 : [(${attrRequestScope})] ``` ### 6. 分支与迭代 #### 1. if
判断
```html if
判断
字符串是否为空 attrRequestScope不为空显示 ~~~attrRequestScope为空显示~~~~ ``` #### 2. 测试
循环
```html 测试
循环
``` > 1. 使用th:each进行集合数据迭代 > 2. th:each="声明变量:${集合}" > 3. th:each 用在哪个标签上,哪个标签就会出现多次 ### 7. 引入外部代码 1. 要被引入的代码 include/part.html ```html 被包含的内容1111 被包含的内容2222 被包含的内容3333 ``` 2. 需要引入的页面 ```html ``` 3. 渲染后的页面源码 ```html 被包含的内容1111 被包含的内容2222 被包含的内容3333 ``` > 1. " :: "左边的值拼前后缀后必须能够找到要包含的文件。 > 2. " :: " 右边的值是代码片段的名字 ,就是th:fragment的值。 > 3. insert将代码原样引入。 > 4. replace使用被引入的代码和属性替换原有的。 > 5. include使用被引入的代码div内部的代码。
Thymeleaf
中文参考手册_3.0.5版_
thymeleaf
_
thymeleaf
中文网_
thymeleaf
文档_thmele
Thymeleaf
中文文档,内容很详细,可用于做API参考。
thymeleaf
_3.0.5_中英文参考手册.zip
thymeleaf
_3.0.5_中英文参考手册;包含中文翻译文档和英文文档
springboot整合
thymeleaf
模板
springboot整合
thymeleaf
模板
springboot与
thymeleaf
结合的实战、实例项目
springboot与
thymeleaf
结合的实战、实例项目,有助于帮助你了解springboot中怎么使用
thymeleaf
。
付强的课程社区_NO_2
1
社区成员
354
社区内容
发帖
与我相关
我的任务
付强的课程社区_NO_2
复制链接
扫一扫
分享
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章