定义:
一个生成文本输出的模板引擎,但不是一个web框架(FreeMarker is a template engine: a generic tool to generate text output )
FreeMarker is not a Web application framework. It is suitable as a component in a Web application framework, but the FreeMarker engine itself knows nothing about HTTP or servlets. It simply generates text. As such, it is perfectly usable in non-web application environments as well. Note, however, that we provide out-of-the-box solutions for using FreeMarker as the view component of Model 2 frameworks such as Struts.
方法:Template + data model = output
DataModel:
| ||
1。The variables that act as directories (the root, animals, mouse, ) are called hashes. Hashes store other subvariables by a lookup name.
2。The variables that store a single value (size, price) are called scalars.
3。similar to hashes, but they don't store names for the variables they contain
The template
FTL tags:
if-else 指令
<#if animals.python.price < animals.elephant.price>
Pythons are cheaper than elephants today.
<#else>
Pythons are not cheaper than elephants today.
</#if>
list指令
|
include指令
注意:
区分大小写;指令不能嵌套;