我有自由人模板
<#import "includes/header.ftl" as header>
<h1>${title}</h1>
header.ftl中的是
<html>
<head>
<title>${title}</title>
</head>
<body>
我有非常简单的代码来呈现它
Configuration cfg = new Configuration();
File dir = new File("/usr/cms/data/templates");
cfg.setDirectoryForTemplateLoading(dir);
cfg.setDefaultEncoding("UTF-8");
cfg.setLocale(Locale.US);
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
Map<String, Object> input = new HashMap<String, Object>();
input.put("title","Test title");
Template template = cfg.getTemplate("template.ftl");
Writer writer = new StringWriter();
template.process(input,writer);
模板已处理,但header.ftl未包含在StringWriter内的字符串中。
如何强制freemarker在处理过程中包含#included文件?
答案 0 :(得分:1)