Unable to load freemarker template using multipartResolver
I am using MultipartFile configured in my Spring MVC app via the classpath:

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    		<property name="maxUploadSize" value="1000000"/>
    	</bean>
    
    <bean id="createSPController" class="myController">
      		<property name="myTemplate" value="classpath:myTemplate.txt"/>
      		
    	</bean>

And I am trying to use freemarker in order to load this templete:

        public class CreateSPController
        {
        	private Resource myTemplate;
        	
        	....
    
            Configuration cfg = new Configuration();
            Template tpl = cfg.getTemplate(myTemplate.getFilename());

But when I run it I am getting an error: **Template classpath:myTemplate.txt not found**

I tried using: `cfg.setDirectoryForTemplateLoading(myTemplate.getFile());`but that leads to the actual file and to the directory it resides it. I suppose I can trim the filename in the second approach but it seems a poor hack to me.

Any ideas...?



Unable to load freemarker template using multipartResolver
===

I am using MultipartFile configured in my Spring MVC app via the classpath:

    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    		<property name="maxUploadSize" value="1000000"/>
    	</bean>
    
    <bean id="createSPController" class="myController">
      		<property name="myTemplate" value="classpath:myTemplate.txt"/>
      		
    	</bean>

And I am trying to use freemarker in order to load this templete:

        public class CreateSPController
        {
        	private Resource myTemplate;
        	
        	....
    
            Configuration cfg = new Configuration();
            Template tpl = cfg.getTemplate(myTemplate.getFilename());

But when I run it I am getting an error: **Template classpath:myTemplate.txt not found**

I tried using: `cfg.setDirectoryForTemplateLoading(myTemplate.getFile());`but that leads to the actual file and to the directory it resides it. I suppose I can trim the filename in the second approach but it seems a poor hack to me.

Any ideas...?


