Configuring Freemarker

Freemarker is one of the popular Java templating engines. We can use Freemarker in Spring applications to generate your View. 

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 JSP, the View resolution can be defined using properties or an XML file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset