在 Apache Tiles 站点的与 FreeMarker 集成页面上,它具有:
To access ".ftl" files as attributes, register FreeMarkerAttributeRenderer this way (only available in a servlet environment):
@Override
protected void registerAttributeRenderers(
BasicRendererFactory rendererFactory, TilesApplicationContext applicationContext,
TilesRequestContextFactory contextFactory,
TilesContainer container, AttributeEvaluator evaluator) {
super.registerAttributeRenderers(rendererFactory, applicationContext, contextFactory,
container, evaluator);
FreeMarkerAttributeRenderer freemarkerRenderer = new FreeMarkerAttributeRenderer();
freemarkerRenderer.setApplicationContext(applicationContext);
freemarkerRenderer.setEvaluator(evaluator);
freemarkerRenderer.setRequestContextFactory(contextFactory);
freemarkerRenderer.setParameter("TemplatePath", "/");
freemarkerRenderer.setParameter("NoCache", "true");
freemarkerRenderer.setParameter("ContentType", "text/html");
freemarkerRenderer.setParameter("template_update_delay", "0");
freemarkerRenderer.setParameter("default_encoding", "ISO-8859-1");
freemarkerRenderer.setParameter("number_format", "0.##########");
freemarkerRenderer.commit();
rendererFactory.registerRenderer("freemarker", freemarkerRenderer);
}
但我不知道我把这段代码放在哪里。您注册此代码的正常位置是什么/我应该扩展和覆盖哪个类?谢谢你的帮助。