title: freemarker templates in several jars
body: <p>How can I configure freemarker to search templates in several jars? With spring.</p>
  
  <pre><code>&lt;!-- freemarker config --&gt;
  &lt;bean id="freemarkerConfig"
      class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"&gt;
      &lt;property name="templateLoaderPaths" value="classpath:/freemarker/" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>One war file (to deploy), and jar file (in dependencies).</p>
  
  <p>One.war</p>
  
  <p>/freemarker/simple.ftl</p>
  
  <p>Two.jar</p>
  
  <p>/freemarker/test.ftl</p>
  
  <p>Work.</p>
  
  <pre><code>ModelAndView mav = new ModelAndView();
  mav.setViewName("simple");
  </code></pre>
  
  <p>Do not work. Can't find test.ftl</p>
  
  <pre><code>ModelAndView mav = new ModelAndView();
  mav.setViewName("test");
  </code></pre>
  
  <p>If settings is:</p>
  
  <pre><code>&lt;property name="templateLoaderPaths" value="classpath:/freemarker/,classpath:/freemarker2/" /&gt;
  </code></pre>
  
  <p>One.war</p>
  
  <p>/freemarker/simple.ftl</p>
  
  <p>Two.jar</p>
  
  <p>/freemarker2/test.ftl</p>
  
  <p>Work.</p>
  
  <pre><code>ModelAndView mav = new ModelAndView();
  mav.setViewName("simple");
  </code></pre>
  
  <p>Work.</p>
  
  <pre><code>ModelAndView mav = new ModelAndView();
  mav.setViewName("test");
  </code></pre>
  
  <p>And question! How configure freemarker to search in several jars(wars) in same path (classpath:/freemarker/)? </p>