thymeleaf 排除list中的某个数据_thymeleaf和SpringBoot的整合

一、thymeleaf和SpringBoot的整合

thymeleaf的好处就是前后端分离

使用thymeleaf与使用freemarker类似的

b3266ae3983f44758faff4a9f2f3b6d0

二、thymeleaf语法

1、thymeleaf的语法都在org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties.class中

26fc746faec3428fbb1ce99a9a91105d

2、只要我们把HTML页面放在classpath:/templates/,thymeleaf就能自动渲染;

注意:

thymeleaf是严格加载HTML5标签的

1、在application-dev.properties文件中配置

d103db9d6cdf4ed89186ae543417d51b

注意:

一但在配置文件中开启了不严格加载

就需要要加载依懒包

835c64fbebc9498798a583bfe794fcec

controller层的跳转

666953942d3f460c9a6a11ee617dd18e

2、再次请求与freemarker类似

36d138f077504bc1b6567e1a3d578ff7

①、thymeleaf 获取数据语法

1、(查询thymeleaf.pdf文档)

②、基本语法

1、th:text;改变当前元素里面的文本内容;

2、th:任意html属性;来替换原生属性的值

df81ba6d1e1a4ea2a4f8e9df56f34a73

③、表达式语法

1、Simple expressions:(表达式语法)

Variable Expressions:${ ...} 获取变量值;OGNL;

1)、获取对象的属性、调用方法

2)、使用内置的基本对象(Expression Basic Objects)

5a85f469d62e49a7b0856842b877ddcc
55e05a2ff2e7439182dbba90e0d7586c

3)、使用内置的工具对象(Expression Utility Objects)

3bd03f8af5a84da9ad532b43e9e313e9
3da948961c9f4c2b82f4f95a6a936368

Selection Variable Expressions: *{...} 与${}类似

82974f8c7f954421af522aef26970621

Message Expressions: #{...} (获取国际化)

Link URL Expressions: @{...}(定义url的链接地址)

bba3baa99df94a0ca9f209206d37f45f

Fragment Expressions: ~{...} //片段的引用

8b4a12c3799648449ec4435d5f53f5ff

2、Literals(字面量 文本/数字/boolean值...)

Text literals: 'one text' , 'Another one!' ,…

Number literals: 0 , 34 , 3.0 , 12.3 ,…

Boolean literals: true , false

Null literal: null

Literal tokens(文字代币): one , sometext , main ,…

3、Text operations(文本操作):

String concatenation: +

Literal substitutions: |The name is ${name}|

4、Arithmetic operations(数学运算):

Binary operators: + , - , * , / , %

Minus sign (unary operator): -

5、Boolean operations(布尔运算):

Binary operators: and , or

Boolean negation (unary operator): ! , not

6、Comparisons and equality(比较运算):

Comparators: > , < , >= , <= ( gt , lt , ge , le )

Equality operators: == , != ( eq , ne )

7、Conditional operators(条件运算(三元运算符)):

If-then: (if) ? (then)

If-then-else: (if) ? (then) : (else)

Default: (value) ?: (defaultvalue)

8、Special tokens(特殊令牌):

Page 17 of 106

No-Operation: _

三、thymeleaf 模板获取数据

1、可查询官网语法https://www.thymeleaf.org/

1、controller层的数据

dc67562a79524182a5e1a8cf5fe0c641

html页面的获取数据

1、 thymeleaf语法提示在HTML中导入

thymeleaf插件安装

72bff0998d0844e294ddce847a9064dc
5e345d89c87d401780f8000957fe6d94

扩展使用thymeleaf引入静态资源的好处

67cf9ab264e34854beec3171bc760606

当在配置文件中配置访问工程的路径地址时,thymeleaf引入静态资源会自动的加上路径地址,无需手动的添加

81ec36721a8f4f5aa38aa3a6d60b2bba

四、thymeleaf 版本的修改

(如安装了Spring的插件会自动的导入最新的版本可以不用修改)

1、查询thymeleaf的版本,可以登录gitHub上进行查询该版本

2、具体是怎么切换版本内?

3、进入SpringBoot官网https://docs.spring.io/spring-boot/docs/1.5.18.BUILD-SNAPSHOT/reference/htmlsingle/#howto-use-thymeleaf-3

4、修改spring-boot-dependencies中对应的版本

d7cbe93ca1654b6ba1ff10a2693ec259
be0c30a25ec7484b8af8897f4bec686e
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值