发布于 2017-03-27 00:01:01 | 110 次阅读 | 评论: 0 | 来源: 网友投递
FreeMarker 基于Java的模板引擎
FreeMarker是一个用Java语言编写的模板引擎,它基于模板来生成文本输出。FreeMarker与Web容器无关,即在Web运行时,它并不知道Servlet或HTTP。它不仅可以用作表现层的实现技术,而且还可以用于生成XML,JSP或Java 等。
Apache FreeMarker 2.3.26-incubating 发布了,这是一个稳定版,加上 "incubating" 是因为 Apache 软件基金会的要求(孵化中的项目),直到该项目成为完全接受(毕业的)Apache 项目为止。关于 FreeMaker 加入 Apache 孵化的新闻。
处于孵化状态的项目不一定是反映了项目代码的完整性或稳定性,不过它确实表明了项目尚未得到 Apache 软件基金会的全面认可。
部分更新如下:
Added node?next_sibling
and node?previous_sibling
to move sideways in a node trees (see reference...). This works with XML DOM nodes, or with any custom TemplateNodeModelEx
implementations.
Added new @@
keys to XML DOM models: @@next_sibling_element
, @@previous_sibling_element
. These get the sibling node if that's an element, with the extra that they silently skip any whitespace text and comment and processing instruction between them. (See more about @@
keys here...)
Bug fixed (FREEMARKER-42): ?first
now works with FTL collections (things that can be listed but doesn't support getting items by index), not only with sequences. The practical importance of this is that ?first
now always works on Java Set
-s (which is useful forSet
-s with well defined ordering), while earlier it has failed depending on the object_wrapper
configuration setting.
或通过配置 Maven 获取:
<dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.26-incubating</version> </dependency>
FreeMarker 是一个模板引擎,一个基于模板生成文本输出的通用工具,使用纯 Java 编写。FreeMarker 被设计用来生成 HTML Web 页面,特别是基于 MVC 模式的应用程序。