springboot集成Thymeleaf模板
目录
一 认识Thymeleaf
二 springboot集成Thymeleaf
三 Thymeleaf的标准表达式
1 标准变量表达式
2 选择变量表达式
3 URL表达式
加了/,就会自动加入项目工程名,如下图
四 Thymeleaf的常见属性
th:action
th:each 循环(比较常用的)
下面是案例代码list示例,数组使用方法一样
以下是map集合的代码示例
th:href (参考上面的url表达式即可)
th:id
后台
前台
th:if
后台model里放了一个字符串1
前台比较判断(eq和=,好像都可以,不确定!!)
th:unless(与if相反,是取反操作)
th:switch/th:case
th:src (图片路径什么的)
th:value
下图相当于input输入框内会有解析出来的phone。如果这里是th:text,那么phone解析后会显示到输入框后面外面,而不是输入框里面
th:attr (给html某元素中某属性赋值)
th:onclick
th:style
th:mothed(直接写method就行,感觉这个没啥用)
th:name
设置表单名称
th:online
先看概念
测试内联文本
测试内联脚本
Thymeleaf的字面量
文本字面量
数字字面量
boolean字面量
null字面量
Thymefeaf字符串拼接
Thymeleaf三元运算符
Thymeleaf运算和关系判断
Thymeleaf表达式基本对象
#request
代码演示
后端放入一个name值
前端取出name值
#session
代码演示
Thymaleaf表达式功能对象
先大概看一下
*代码举例1 :格式化时间格式
前端取出时间并格式化显示
代码示例2:字符串截取
真正使用时查官方文档
函数示例