【发布时间】:2012-03-29 02:41:14
【问题描述】:
我正在使用通过类路径在我的 Spring MVC 应用程序中配置的 MultipartFile:
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="1000000"/>
</bean>
<bean id="MyController" class="myController">
<property name="myTemplate" value="classpath:myTemplate.txt"/>
</bean>
我正在尝试使用 freemarker 来加载这个模板:
public class MyController
{
private Resource myTemplate;
....
Configuration cfg = new Configuration();
Template tpl = cfg.getTemplate(myTemplate.getFilename());
但是当我运行它时出现错误:Template classpath:myTemplate.txt not found
我尝试使用:cfg.setDirectoryForTemplateLoading(myTemplate.getFile().getParentFile()) 来确定目录,但这也无济于事。
有什么想法吗...?
【问题讨论】:
标签: spring-mvc freemarker