我有一个Spring / JSF Web应用程序,它依赖于模块使用Freemarker模板.这是我为整合做的事情:
我将applicationContext-freemarker-module.xml导入applicationContext.xml
我将配置bean添加到applicationContext-freemarker-module.xml,如下所示.
figuration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationfactorybean">
sspath*:/"/>
我把模板放到freemarker模块的src / main / resources目录下.
我正在阅读如下模板:
ApplicationContext context = new ClasspathXmlApplicationContext("applicationContext-freemarker-module.xml");
Configuration templateConfig = (Configuration) context.getBean("freemarkerConfiguration");
Template template = templateConfig.getTemplate("template.ftl");
现在我为templateLoaderPath属性尝试了很多值,但我总是得到“找不到模板”.例外.
Freemarker模块的JAR如下所示
template.ftl
applicationContext-freemarker-module.xml
com/.../ (classes)
meta-inf
我应该在哪里放模板文件,我应该为templateLoaderPath值设置什么?
我无法理解为什么找不到“template.ftl”.我试图设置正确的值数小时.我尝试了各种路径配置但没有成功.
非常感谢你的帮助,
>在* -action servlet中,xml FreeMarkerConfigurationfactorybean配置将“preferFileSystemAccess”属性设置为“false”
>< property name =“templateLoaderPath”value =“classpath *:/”/>应该
< property name =“templateLoaderPath”value =“classpath:/”/>
在freemarker中,模板加载器尝试匹配字符串“classpath:”,而不是“classpath *:”
>您在WEB-INF / lib文件夹下有JAR文件.
>最后,您的模板文件位于jar文件的根目录下.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。