title: Importing spring.ftl using Spring MVC, Sitemesh, Freemarker
body: <p>How can I import the spring.ftl macros into a Freemarker template page using Spring MVC, Sitemesh, and Freemarker?</p>
  
  <p>I've configured a Spring MVC app using Sitemesh and Freemarker based on <a href="http://tedyoung.me/2011/02/14/spring-sitemesh-and-freemarker/">Ted Young's configuration example</a>. According to the <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#view-velocity">Spring MVC/Freemarker</a> integration reference, it is necessary to import the spring.ftl macros in order to bind the backing model to the view via &lt;@spring.bind "command.name"/>. However, doing this:</p>
  
  <pre><code>&lt;#import "/spring.ftl" as spring&gt;
  &lt;@spring.bind "command.user"/&gt;
  </code></pre>
  
  <p>Results in this exception:</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: 
  Request processing failed; nested exception is freemarker.
  template.TemplateException: Error reading imported file spring.ftl
  </code></pre>
  
  <p><a href="http://forum.springsource.org/showthread.php?55855-Error-reading-imported-file-spring-ftl">Others have experienced this issue</a>, but I've yet to find a solution in google land. I also attempted to use <a href="http://tedyoung.me/2011/02/19/freemarker-jsp-taglibs-outside-war/#more-227">this technique</a> (zipping up spring.ftl, placing it in META-INF/lib, and adding the zip to the build path), but it didn't seem to work out.</p>
  
  <p>Thanks!</p>