在我的应用程序,所有的freemarker模板是/模板/ FTL /所以应用程序部署期间我打开一个类我称之为扩展FreemarkerManager并有一个方法Freemarker模板装载
Configuration configuration = super.createConfiguration(servletContext);
configuration.setDirectoryForTemplateLoading(new File("/templates/ftl/"));
这样一类当我需要加载一个模板文件,我可以简单地做这样的:
ServletContext servletContext = ServletActionContext.getServletContext();
Configuration configFreemarker = (Configuration) servletContext
.getAttribute("freemarker.Configuration");
Template template = configFreemarker.getTemplate("pathToMyTemplate");
在只有一个特定的情况下,我需要得到来自完全不同的道路(不是/模板/ FTL模板/)。
如何在此特定时刻为模板加载声明第二个目录而不破坏所有调用旧路径的现有代码?我可以同时有两个不同的模板加载起点吗?
谢谢
也许只是建立一个没有独立的(或临时)配置特定的目录? – 2013-03-28 08:46:37
我看不到怎么可能实例化2配置,因为我的类需要扩展FreemarkerManager,在那里我需要扩展我已经做了第一次的createConfiguration方法。里面我得到配置conf = super.createConfiguration(servletContext);但我没有看到我怎么能得到相同的servletContext – gospodin 2013-03-28 09:13:50