zoukankan      html  css  js  c++  java
  • thymeleaf:总结

    Thymeleaf定义:Thymeleaf is a modern server-side Java template engine for both web and standalone environments, capable of processing HTML, XML, JavaScript, CSS and even plain text.

    Thymeleaf可以处理的模板类型有:HTML XML TEXT JAVASCRIPT CSS RAW

    Thymeleaf的方言简单易用,且不会破坏HTML的结构,这项特性被称为自然模板。

    假如采用SpringMVC渲染Thymeleaf视图,一个简易的视图文件home.html文件:

    <!DOCTYPE html>
    
    <html xmlns:th="http://www.thymeleaf.org">
    
      <head>
        <title>Good Thymes Virtual Grocery</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" media="all" 
              href="../../css/gtvg.css" th:href="@{/css/gtvg.css}" />
      </head>
    
      <body>
      
        <p th:text="#{home.welcome}">Welcome to our grocery store!</p>
        
        <p>Today is: <span th:text="${today}">13 February 2011</span></p>
      
      </body>
    
    </html>

    这个 xmlns:th="http://www.thymeleaf.org" 并不是h5中的元素,这个对整个模板的渲染并没有任何影响,但是在可以避免IDE在解释 th:* 属性缺失时报错。 也可以用 data- 前缀和 短横线 - 来替换冒号 : 这样就 th:text 可以变成 data-th-text 

    取变量的值是采用 ${ }

    遍历list的语法是 th:each

        <table>
          <tr>
            <th>NAME</th>
            <th>PRICE</th>
            <th>IN STOCK</th>
          </tr>
          <tr th:each="prod : ${prods}">
            <td th:text="${prod.name}">Onions</td>
            <td th:text="${prod.price}">2.41</td>
            <td th:text="${prod.inStock}? #{true} : #{false}">yes</td>
          </tr>
        </table>

    END

  • 相关阅读:
    ThreadLocal全面解析,一篇带你入门
    StringTable字符串常量池的垃圾回收跟踪案例
    air镶边引7yue
    性能优化与团队效率
    air 错误信息一览
    AS3 使用unloadAndStop()卸载加载的swf以及里面的声音
    flash/flex/as3应用程序加载as2、as1版本的swf遇到的问题
    查看swc的代码
    chart 属性
    flex动态控制 effect
  • 原文地址:https://www.cnblogs.com/colin220/p/10432035.html
Copyright © 2011-2022 走看看