Thymeleaf HTML5模板引擎

2019-07-25 18:15:23 浏览数 (1)

Thymeleaf的模板还可以用作工作原型,Thymeleaf会在运行期替换掉静态值。例如下面的html文件,当作为静态文件时,product name显示为Red Chair,当运行在容器中并提供product这个对象时,product name的值会自动替换为product.description对应的值。

代码语言:javascript复制
<!DOCTYPE html> 
<html xmlns:th="http://www.thymeleaf.org">
  <head>   
<title>Thymeleaf tutorial: exercise 13</title> 
  <link rel="stylesheet" href="../../../css/main-static.css" th:href="@{/css/main.css}" />   <meta charset="utf-8" />  </head> 
 <body>  
 <h1>Thymeleaf tutorial - Solution for exercise 13: inlining</h1> 
  <h2>Birthday email</h2>   
<form action="#" method="post">   
 <label for="body">Message body:</label> <textarea id="body" name="body" th:inline="text"> Dear [[${customerName}]],
it is our sincere pleasure to congratulate your in your birthday:  Happy birthday [[${customerName}]]!!!
See you soon, [[${customerName}]].
Regards,  The Thymeleaf team </textarea>
    <input type="submit" value="Send mail" /> 
  </form>  
</body> 
</html>
代码语言:javascript复制
<input data-validation-matches-message="Text from messages resources" />
代码语言:javascript复制
<input th:attr="data-validation-matches-message=''   #{user.notfound}"   '''"/>
代码语言:javascript复制
解决地址:http://stackoverflow.com/questions/21801158/thymeleaf-custom-attribute

0 人点赞