我的应用程序在tomcat 6中运行。我已将freemarker模板与Spring MVC集成。
I have "abct.ftl" under "freemarker/pages" and "xyz.ftl" under "freemarker/pages
/formal". I am including "abc.ftl" in "xyz.ftl" using "<#include
"../abc.ftl"/>".
This is working fine on MACH and LINUX but its giving below error on windows 7. I did search
for this error in google and tried many things but nothing helped fixing this issue.
The exception stack trace is given below:
freemarker.template.TemplateException: Error reading included file abc.ftl
at freemarker.core.Include.accept(Include.java:167)
Caused by: java.io.FileNotFoundException: Template abc.ftl not found.
Please help me fixing this issue.
Thanks
答案 0 :(得分:0)
感谢大家帮助我解决这个问题。 我找到了这个问题的解决方案,所以想和你们分享。
我在freemarker网站上浏览了以下文档并找到了解决方案:
http://freemarker.org/docs/pgui_config_templateloading.html#autoid_41 [freemarker.org]
正如本文档中所建议的,我更换了&lt; #include&#34; ../ abc.ftl&#34; /&gt;与&lt; #include&#34; /pages/abc.ftl" /&gt;。
Freemarker文档说,“FreeMarker在将路径传递给模板加载器之前总是规范化路径,因此路径不包含/../等,并且相对于虚构的模板根目录。”
模板根目录是我们在templateLoaderPath中指定的目录:
属性名称=&#34; templateLoaderPath&#34;值=&#34;类路径:/的freemarker&#34;
我测试了Windows,Linux,Mach以及它在任何地方工作的这个修复程序。
由于