一、引用命名空间 <html xmlns:th="http://www.thymeleaf.org">

在html中引入此命名空间,可避免编辑器出现html验证错误,虽然加不加命名空间对Thymeleaf的功能没有任何影响。

二. 取值

  #{home.welcome} --  访问数据

#{home.welcome(${session.user.name})}  -- 格式化数据 当 home.welcome 为 "abcdegf{0}"  类似这种内容时。(多个参数以逗句分隔)。

  ${today} --- 访问变量

  日期的输出 <span th:text="${#calendars.format(today,'dd MMMM yyyy')}">13 May 2011</span>

三、访问对象

${param.x} 返回名为x 的 request参数。(可能有多个值)

${session.x} 返回名为x的Session参数。

${application.x} 返回名为 servlet context 的参数 

  星号语法

  <div th:object="${session.user}">
    <p>Name: <span th:text="*{firstName}">Sebastian</span>.</p>
    <p>Surname: <span th:text="*{lastName}">Pepper</span>.</p>
    <p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p>
  </div>

  输出URL

<a href="product/list.html" th:href="@{/product/list}">Product List</a>

<a href="details.html" th:href="@{/order/{orderId}/details(orderId=${o.id})}">view</a>

  直接输出内容

  <span th:text="'working web application'"> -- 输出字符

  <span th:text="2013 + 2">  -- 输出数据表达式

  <div th:if="${user.isAdmin()} == false">  --输出布尔表达式

  <span th:text="'Welcome to our application, ' + ${user.name} + '!'"> -- 带变量的

  条件表达式

  <tr th:class="${row.even}? 'even' : 'odd'">
  ...  
  </tr>

循环输出的语法

6.1 基本循环

<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>
  <tr>
  <th>NAME</th>
  <th>PRICE</th>
  <th>IN STOCK</th>
  </tr>
  <tr th:each="prod,iterStat : ${prods}" th:class="${iterStat.odd}? 'odd'">
  <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>

关于状态的其它信息的使用详细参考:http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#keeping-iteration-status

  更多详情的说明和规则请参见:http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#introducing-thymeleaf

thymeleaf html5的更多相关文章

  1. SpringMvc+thymeleaf+HTML5中文乱码问题

    SpringMvc+thymeleaf+HTML5环境下遇到中文乱码...... 按照以往经验逐个排查,开发环境统一为utf-8编码,服务器也配置了编码过滤器,tomcat也是utf-8编码.前台页面 ...

  2. Spring boot配合Spring session(redis)遇到的错误

    背景:本MUEAS项目,一开始的时候,是没有引入redis的,考虑到后期性能的问题而引入.之前没有引用redis的时候,用户登录是正常的.但是,在加入redis支持后,登录就出错!错误如下: . __ ...

  3. SpringBoot接口服务处理Whitelabel Error Page(转)

    To switch it off you can set server.error.whitelabel.enabled=false http://stackoverflow.com/question ...

  4. Whitelabel Error Page 专题

    Spring boot为错误视图提供了如下错误属性:timestamp:错误发生的时间status:HTTP状态码error:错误原因exception:异常的类名message:异常消息(如果这个错 ...

  5. SpringBoot接口服务处理Whitelabel Error Page

    转载请注明来源:http://blog.csdn.net/loongshawn/article/details/50915979 <SpringBoot接口服务处理Whitelabel Erro ...

  6. 【Thymeleaf】Thymeleaf模板对没有结束符的HTML5标签解析出错的解决办法

    解决方案 spring: thymeleaf: mode: LEGACYHTML5 <dependency> <groupId>net.sourceforge.nekohtml ...

  7. HTML5模板引擎 Thymeleaf 教程(转)

    原文:http://www.open-open.com/lib/view/open1383622135586.html Thymeleaf是一个XML/XHTML/HTML5模板引擎,可用于Web与非 ...

  8. 解决thymeleaf严格html5校验的方法

    用的是springboot加thyemleaf做静态模板. 然后会有个很烦的东西,就这个静态模板对html的格式非常严格,导致很多框架的格式都用不了,然后这里有个解除的方法: 1.在pom中添加依赖: ...

  9. sprintboot + mybaits + mysql + html5 + thymeleaf 个人笔记

    参考:https://github.com/daleiwang/moxi service @Mapper 与 @Select 等 @Mapper似乎是一个myBaits 注解,表示将java方法和sq ...

随机推荐

  1. Educational Codeforces Round 76 (Rated for Div. 2)E(最长上升子序列)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;int a[200007],b[200007] ...

  2. 计算机二级-C语言-对标志位的巧妙使用。对二维数组数据进行处理。对文件进行数据输入。

    //函数fun的功能是:计算形参x所指数组中平均值(规定所有数均为正数),将所指数组中大于平均值的数据移至数组的前部,小于等于的移至后部,平均值作为返回值,在主函数中输出平均值和后移的数据. //重难 ...

  3. leetCode练题——28. Implement strStr()

    1.题目 28. Implement strStr()——Easy Implement strStr(). Return the index of the first occurrence of ne ...

  4. 「CF1142B」Lynyrd Skynyrd

    传送门 Luogu 解题思路 发现一个性质: 对于排列的任何一个循环位移,排列中的同一个数的前驱肯定是不变的. 而且,如果一个排列的循环位移是某一个区间的子序列,那么这个循环位移的结尾的 \(n-1\ ...

  5. 比较好的IT教程网

    MDN最完整的Web标准,Webapi                https://developer.mozilla.org/zh-CN/docs/Web 主要几个比较常用教程网都可以 gitbo ...

  6. Java学习资源 - 其他

    http请求HttpServletRequest详解 HttpServletRequest请求转发 高并发场景下的httpClient优化使用 HttpClien高并发请求连接池 - PoolingH ...

  7. IKAnalyzer使用

    1.分析器 所有分析器最终继承的类都是Analyzer 1.1 默认标准分析器:StandardAnalyzer 在我们创建索引的时候,我们使用到了IndexWriterConfig对象,在我们创建索 ...

  8. java操作nginx

    一,判断程序的部署环境是nginx还是windows /** * 判断操作系统是不是windows * * @return true:是win false:是Linux */ public stati ...

  9. 一个高级PHP工程师所应该具备的(转自元如枫博客)

    初次接触PHP,就为他的美所折服,于是一发不可收拾. 很多面试,很多人员能力要求都有“PHP高级工程师的字眼”,如果您真心喜欢PHP,并且您刚起步,那么我简单说说一个PHP高级工程师所应该具备的,希望 ...

  10. org.springframework.web.multipart.MultipartException: The current request is not a multipart request

    今天做图片上传的碰到这个问题,查找原因是html请求的方式问题.from中涉及到图片上传的就要用post提交方式.否则就会报这个错误.如果已经是post的提交方式了还有这个错...还有两种解决方法. ...