在Eclipse Maven项目 Spring4 MVC 配置 Freemarker视图时报错
在spring-mvc.xml中添加如下块
<!-- freemarker config --> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="templateLoaderPath" value="/WEB-INF/freemarker/" /> </bean>
之后,Eclipse显示:
Multiple annotations found at this line: - No setter found for property 'templateLoaderPath' in class 'org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer'
在网上找到了一些热心网友的提示:
http://viralpatel.net/blogs/spring-mvc-freemarker-ftl-example/
Adam McCormick 25 June, 2013, 9:41 You need to include spring-context-support.jar. FreeMarkerConfigurationFactory was moved. See: https://jira.springsource.org/browse/SPR-10233?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
说是需要一个 spring-context-support.jar 的包
由于项目是Maven的,所以,在项目的pom.xml中添加 dependency
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.0.4.RELEASE</version> </dependency>
【额外发现 : 】
两种Freemarker模板路径设置方法
基于注解的SpringMVC+freemarker环境搭建