- Mastering Spring 5.0
- Ranga Rao Karanam
- 54字
- 2021-07-02 22:12:16
Configuring Freemarker
The following example shows the typical approach used to configure a Freemarker view resolver.
First, the freemarkerConfig bean is used to load the Freemarker templates:
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.
freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-
INF/freemarker/"/>
</bean>
The following bean definition shows how to configure a Freemarker view resolver:
<bean id="freemarkerViewResolver"
class="org.springframework.web.servlet.view.
freemarker.FreeMarkerViewResolver">
<property name="cache" value="true"/>
<property name="prefix" value=""/>
<property name="suffix" value=".ftl"/>
</bean>
As with JSPs, the view resolution can be defined using properties or an XML file.