File rootFile = webAppFolder.getAbsoluteFile();
while (rootFile.getParentFile() != null) {
rootFile = rootFile.getParentFile();
}
MultiTemplateLoader mtl;
TemplateLoader[] loaders = null;
// ////////// Set the templateLoaders ////////////////
// if we have a servletContext, then include a webappTemplateLoader
try {
if (servletContext != null) {
WebappTemplateLoader webappTemplateLoader = new WebappTemplateLoader(servletContext);
TemplateLoader tl = new FileTemplateLoader(rootFile, true);
loaders = new TemplateLoader[] { tl, webappTemplateLoader };
} else {
TemplateLoader tl = new FileTemplateLoader(rootFile, true);
loaders = new TemplateLoader[] { tl };
}
} catch (IOException e) {
logger.error(e.getMessage());
}
if (loaders != null) {
mtl = new MultiTemplateLoader(loaders);
conf.setTemplateLoader(mtl);
}
// set the BeanWrapper
conf.setObjectWrapper(BeansWrapper.DEFAULT_WRAPPER);