如何使用Spring MVC,Sitemesh和Freemarker将spring.ftl宏导入Freemarker模板页面?
我根据Ted Young的配置示例使用Sitemesh和Freemarker配置了一个Spring MVC应用程序.根据Spring MVC/Freemarker集成参考,有必要导入spring.ftl宏,以便通过<@ spring.bind"command.name"/>将支持模型绑定到视图.但是,这样做:
<#import "/spring.ftl" as spring>
<@spring.bind "command.user"/>
Run Code Online (Sandbox Code Playgroud)
此例外的结果:
org.springframework.web.util.NestedServletException:
Request processing failed; nested exception is freemarker.
template.TemplateException: Error reading imported file spring.ftl
Run Code Online (Sandbox Code Playgroud)
其他人已经遇到过这个问题,但我还没有找到谷歌的解决方案.我也试图使用这种技术(压缩spring.ftl,将它放在META-INF/lib中,并将zip添加到构建路径中),但它似乎没有成功.
谢谢!