zoukankan      html  css  js  c++  java
  • thymeleaf

    官方网站:http://www.thymeleaf.org/

     thymeleaf简介

     Thymeleaf 是一个跟 Velocity、FreeMarker 类似的模板引擎,它可以完全替代 JSP 。相较与其他的模板引擎,它有如下三个极吸引人的特点:

        1.Thymeleaf 在有网络和无网络的环境下皆可运行,即它可以让美工在浏览器查看页面的静态效果,也可以让程序员在服务器查看带数据的动态页面效果。这是由于它支持 html 原型,然后在 html 标签里增加额外的属性来达到模板+数据的展示方式。浏览器解释 html 时会忽略未定义的标签属性,所以 thymeleaf 的模板可以静态地运行;当有数据返回到页面时,Thymeleaf 标签会动态地替换掉静态内容,使页面动态显示。

        2.Thymeleaf 开箱即用的特性。它提供标准和spring标准两种方言,可以直接套用模板实现JSTL、 OGNL表达式效果,避免每天套模板、改jstl、改标签的困扰。同时开发人员也可以扩展和创建自定义的方言。

        3. Thymeleaf 提供spring标准方言和一个与 SpringMVC 完美集成的可选模块,可以快速的实现表单绑定、属性编辑器、国际化等功能。

    表达式

    变量表达式"${  }" 

    <span th:text="${book.author.name}">

    消息表达式"#{  }" 

    <span th:text="#{book.author.name}">

    (文本外部化、国际化、i18n)

    选择表达式"*{  }" 

    <div th:text="${book}">
        <span th:text="*{name}"></span>
    </div>

    链接表达式 "@{  }"

    <a th:href="@{../doucments/report}">...</a>
    <a th:href="@{~/doucments/report}">...</a>
    <a th:href="@{//static.mycompany.com/report}">...</a>
    <a th:href="@{http://www.mycompany.com/doucments/report}">...</a>

    分段表达式 th:insert th:replace

    <!doctype html>
    <html xmls:th="http://www.thymeleaf.org">
        <body>
            <div th:fragment="copy">
                &copy; 2017 <a href="https//waylau.com">waylau.com</a>
        </body>
    </html>
    <body>
        ...
        <div th:insert="~{foot :: copy }"></div>
    </body>

    字面量

    文本

    <p>
        Now you are looking at a <span th:text="'working web application'">template file</span>.
    </p>

    数字

    <p>
        The year is <span th:text="2013">1492</span>.
    </p>

    布尔 true、false

    空 null

    算术操作

    +、-、*、/、%

    比较:>、<、>=、<=(gt、lt、ge、le)

    等价 :==、!= (eq ne)

    三目运算符 ? :

    无操作 _

    字面量(文字)

    null

    <div th:if="${variable.something} ==null"></div>

    参考资料:https://github.com/waylau/thymeleaf-tutorial

  • 相关阅读:
    关于字符函数的一些应用总结
    常用数字函数简单举例
    dump浅析B树索引
    pl/sql developer 登陆sys用户
    关于oracle11g简单的网络配置
    关于oracle数据库读取数据的三种方式
    创建表
    SQL*Plus 与数据库的交互
    Oracle编程艺术--配置环境
    MongoDB--(NoSQL)入门介绍
  • 原文地址:https://www.cnblogs.com/Jxiaobai/p/7291681.html
Copyright © 2011-2022 走看看