Eclipse Maven項目 Spring4 MVC 配置 Freemarker視圖添加 templateLoaderPath 時報錯


在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環境搭建


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章