用Thymeleaf替换JSP
作者:chszs,转载需注明。博客主页:http://blog.youkuaiyun.com/chszs
Thymeleaf是一个Java库。它是XML、XHTML、HTML5等格式的模板引擎,可以用于Web项目和非Web项目。Thymeleaf很适合作为Web应用的视图的业务逻辑层,还可以在离线环境下处理XML文件。

Thymeleaf可以作为Spring MVC的可选模块,也可以直接作为JSP的替代。Thymeleaf提供了两个版本,分别是Standard方言与SpringStandard(Spring MVC 3)方言,并且可以通过创建自定义方言进行扩展。
Thymeleaf的主要目标在于提供一种可被浏览器正确显示的、格式良好的模板创建方式,因此也可以用作静态建模。
Thymelea模板引擎与Velocity、FreeMarker相似。
代码例子:
<table> <thead> <tr> <th th:text="#{msgs.headers.name}">Name</th> <th th:text="#{msgs.headers.price}">Price</th> </tr> </thead> <tbody> <tr th:each="prod : ${allProducts}"> <td th:text="${prod.name}">Oranges</td> <td th:text="${#numbers.formatDecimal(prod.price,1,2)}">0.99</td> </tr> </tbody></table>
今天(2013.11.4日),Thymeleaf发布了最新的2.1.0版。
下载地址:https://sourceforge.net/projects/thymeleaf/files/thymeleaf/2.1.0.RELEASE/
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.youkuaiyun.com/jiangjunshow