thymeleaf 缓存_可能是最全的Thymeleaf参考手册:终极篇,全,全,全!!!

这是一份详尽的Thymeleaf参考手册,涵盖从配置到模板缓存的各个方面。它深入探讨了标准表达式语法、属性设置、迭代、条件评估等核心概念,并讨论了Thymeleaf与Spring Framework和Spring Security的集成。此外,还介绍了Thymeleaf在Eclipse中的插件支持,提供了强大的代码补全和模板调试功能,以及如何利用Thymeleaf-extras-springsecurity库简化安全配置。
摘要由CSDN通过智能技术生成
5a42256b3fa9ca007b32f23e18ba513a.gif Thymeleaf是一个现代的、服务器端的Java模板引擎,适用于Web和独立环境。其主要目标是为开发工作流程带来异常优雅的自然模板——可以在浏览器中正确显示HTML,也可以作为静态原型,使开发团队协作更通畅。 目前Thymeleaf已于Spring Framework集成,相信凭借Spring Framework的出色特性,能使Thymeleaf成为现代HTML5 JVM Web开发的首选。 Thymeleaf全部的参考手册如下:
  • 可能是最全的Thymeleaf参考手册(一):配置
  • 可能是最全的Thymeleaf参考手册(二):标准表达式语法(一)
  • 可能是最全的Thymeleaf参考手册(三):标准表达式语法(二)
  • 可能是最全的Thymeleaf参考手册(四):标准表达式语法(三)
  • 可能是最全的Thymeleaf参考手册(五):设置属性值
  • 可能是最全的Thymeleaf参考手册(六):迭代
  • 可能是最全的Thymeleaf参考手册(七):条件评估
  • 可能是最全的Thymeleaf参考手册(八):模板布局
  • 可能是最全的Thymeleaf参考手册(九):局部变量
  • 可能是最全的Thymeleaf参考手册(十):优先级
  • 可能是最全的Thymeleaf参考手册(十一):注释和块
  • 可能是最全的Thymeleaf参考手册(十二):内联
  • 可能是最全的Thymeleaf参考手册(十三):文本模板模式
  • 可能是最全的Thymeleaf参考手册(十四):其它配置
  • 可能是最全的Thymeleaf参考手册(十五):模板缓存
  • 可能是最全的Thymeleaf参考手册(十六):模板解耦逻辑

另外,Thymeleaf还有其它官方的工具和扩展库。 Thymeleaf测试库 https://github.com/thymeleaf/thymeleaf-testing Thymeleaf测试库允许开发人员以非常简单和声明性的方式为Thymeleaf应用程序和扩展创建自动测试。其功能包括:
  • 作为独立的库工作,可以从多个测试框架(例如JUnit)中调用
  • 仅测试视图层:模板处理及其结果。
  • 允许将测试输入指定为标记片段,也可以指定为正在开发的基于Thymeleaf的应用程序的模板文件的链接,以便轻松测试其视图层
  • 通用的测试工件:测试序列,迭代,并发执行...
  • Spring FrameworkSpring Security 集成。
测试规范可以这样简单:
%TEMPLATE_MODE HTML5# ------------ separator comment -----------%CONTEXTonevar = "Goodbye,"# ------------------------------------------%MESSAGESone.msg = Crisis# ------------------------------------------%INPUT<html>  <body>    <span th:text="${onevar}">Hello,span>    <span th:text="#{one.msg}">World!span>  body>html># ------------------------------------------%OUTPUT<html><body>  <span>Goodbye,span>  <span>Crisisspan>body>html>

Thymeleaf Eclipse插件

https://github.com/thymeleaf/thymeleaf-extras-eclipse-plugin

用于Eclipse IDE的Thymeleaf插件添加了内容辅助功能,使在Thymeleaf模板中的工作变得更好,更舒适。

  • Thymeleaf属性处理器的 代码完成。
  • 每个属性的详细说明。
  • 表达式内的内容辅助:表达式实用程序对象

68c86e7ae95bcf667f48d6d92ada90c3.png

Thymeleaf + Spring Security

https://github.com/thymeleaf/thymeleaf-extras-springsecurity

Thymeleaf Extras Spring Security库提供了一种方言,可以将Spring Security的多个授权和身份验证方面(版本3.x,4.x和5.x)集成到基于Thymeleaf的应用程序中。特征:
  • 基于Thymeleaf的等效于Spring Security JSP的标签库
  • 添加新的表达式实用程序对象,例如 #authentication 和 #authorization,用于将Spring Security功能集成到Thymeleaf表达式中
  • 添加新的属性,例如 sec:authentication 和 sec:authorized以简化安全性配置。

使用此库,可以轻松使用Spring Security中定义的基于角色的访问限制:

<div sec:authorize="hasRole('ROLE_ADMIN')">  This will only be displayed if authenticated user has role ROLE_ADMIN.div>

与安全性相关的对象也可以包含在普通的Thymeleaf表达式中:

"${#authentication.name}"> The value of the "name" property of the authentication object should appear here.</div>

Thymeleaf + IE条件注释

https://github.com/thymeleaf/thymeleaf-extras-conditionalcomments

Thymeleaf Extras条件注释库为Thymeleaf模板中的Internet Explorer 条件注释提供了支持。 在条件注释中 处理Thymeleaf 属性处理器。支持条件注释的整个语法。IE条件注释如下所示:

并且由于有了这个库,它们可以像下面的代码一样正确执行:

另外,Thymeleaf用户在Thymeleaf项目之外开发和维护,并根据其自己的许可和支持条款进行分发。如Thymeleaf Layout DialectThymeleaf Cache Dialect、Data Attribute DialectThymeleaf Spring Data Dialect等,感兴趣的,可根据以下地址查看其相关信息。

Thymeleaf Layout Dialecthttps://github.com/ultraq/thymeleaf-layout-dialectThymeleaf Cache Dialecthttps://github.com/Antibrumm/thymeleaf-extras-cache-dialectData Attribute Dialecthttps://github.com/mxab/thymeleaf-extras-data-attributeThymeleaf Spring Data Dialecthttps://github.com/jpenren/thymeleaf-spring-data-dialect

e4cd497cd6b4fd4a5ea32bd7d415cb7c.gif

- End -

613deff17790ba151593bd5a93e3c035.gif

回复以下关键字,获取更多资源

SpringCloud进阶之路 | Java 基础 | 微服务 | JAVA WEB | JAVA 进阶 | JAVA 面试 | MK 精讲

613deff17790ba151593bd5a93e3c035.gif

往期精选

2ef3bec8b9d875da7cef5ce4fdcea547.png5fd9f8c99b0586af2e18218b13f89f68.png 

可能是最全的Thymeleaf参考手册(一):配置

ribbon,不带这么坑人的!

Spring Cloud进阶之路 | 十二:断路器聚合监控(Turbine)

面试宝典(一):除零问题

重温Java基础(七):位运算符

避坑指南(四):zuul整合断路器监控线程池一直loading

docker进阶之路-基础篇 | 二:protainer安装与使用

集群式Quartz定时任务框架实践

如果喜欢我们的文章

可以关注我们

也可以点击右下角的在看告诉我们

期待与您相遇

92b8c959bd85ebeab5e6deb3a0df905d.png

点“在看”你懂得

57309cc6b749a939ab1b9cd9d673e6df.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值