1.数字格式化:
th:text="${#numbers.formatDecimal(product.price, 1, 2)}" 850.00
2.日期格式化:
th:text="${#dates.format(product.availableFrom, 'dd-MMM-yyyy')}" 18-二月-2013
th:text="${#dates.format(product.availableFrom, 'yyyy-MM-dd hh:ss:mm')}" 2013-02-18 12:00:00
3.字符串拼接:
th:text="${'$' + #numbers.formatDecimal(product.price, 1, 2)}" $850.00
<span th:text="'Hello ' + ${customerName} + '!'">Hello, Peter!</span>
<span th:text="'Hello __${customerName}__!'">Hello, Peter!</span>
<span th:text="|Hello ${customerName}!|">Hello, Peter!</span>
4.国际化:
messages_en:
tutorial.exercise4=Thymeleaf tutorial - exercise 4: internationalization
product.info=Product information
product.name=Product name
product.price=Product price
product.available=Product available from
back=Back
<h1 th:text="#{tutorial.exercise4}">Thymeleaf tutorial - Solution for exercise 4: internationalization</h1>
<h2 th:text="#{product.info}">Product information</h2>
<dt th:text="#{product.name}">Product name</dt>
<dt th:text="#{product.price}">Product price</dt>
5.打印标签:
<div th:text="${html}">
Some escaped text
</div>
This is an <em>HTML</em> text. <b>Enjoy yourself!</b>
6.解析标签:
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载