对FreeMarker而言,无非是Template + data-model = output。 这里,假设我们所要生成的Java代码,即output如下:
对FreeMarker而言,无非是“Template + data-model = output”。 这里,假设我们所要生成的Java代码,即“output”如下:
其中,类名、属性都属于“data-model”,其可用树形结构表现如下: (root) | +- class = “F32B” | |- properties | | | +- currency | | | | | +- name = “currency” | | | | | +- type = “String” | | | +- amount | | | | | +- name = “amount” | | | | | +- type = “Double” 那么,则可使用如下“Template”:
最后,将FreeMarker文档中的例子改动一下,测试生成“output”的Java程序如下:
|