首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

freemarker能否嵌套解决方案

2012-03-09 
freemarker能否嵌套freemarker模板中能否嵌入模板?就好象jsp页面中能嵌入另外一个jsp一样?[解决办法]可以

freemarker能否嵌套
freemarker模板中能否嵌入模板?就好象jsp页面中能嵌入另外一个jsp一样?

[解决办法]
可以啊
[解决办法]
正在学习中,顶一下了!
[解决办法]
myTemplate.ftl

<#macro student name age>
大家好:我是${name},今年${age}岁.<#nested>
</#macro>
-------------------------
template.ftl
<#import "/src/macro/myTemplate.ftl" as my/>
<@my.student name="樊海" age="25">
123
</@my.student>
[解决办法]

public class FreeMarkerTest {

public static void main(String[] args) throws Exception {
UpperDirective upper = new UpperDirective();
Map map = new HashMap();
map.put("upper", upper);
Template template = FreeMarkerUtil.getTemplate("src\\macro\\template.ftl");
File htmlFile = new File("src\\macro\\freemaker.htm");
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFile)));
template.process(map, writer);
}
}

热点排行