$${special.cost}
</li>
</#list>
</ul>
As you can see, it’s not terribly difficult to get a basic templating solution in place as the
view layer. Let’s go a little deeper and look at some of the more advanced configurations and
also what Spring offers in the way of bind support for Velocity and FreeMarker.
Many properties and settings can be used to affect the way your templating engine operates.
Certain properties will determine how templates are loaded and cached, how locales are man-
aged, how macros are handled, and more. All of these are beyond the scope of this book, but if
you are looking at Velocity or FreeMarker for the first time, we strongly recommend that you
familiarize yourself with all these options.
To hook into these advanced options, you can specify the location of an external proper-
ties file (you may have one of these if you’ve previously used Velocity or FreeMarker outside
of a Spring application). On the configurer object, set the property named configLocationto
wherever the configuration file may be found. The value of configLocationis interpreted as
a Spring Resource,which means you can use classpath, file, or URL-based locations. See the
Spring reference documentation for information about Spring Resources. You can alternatively
set such properties locally on the configurer instance if you have no need to use those proper-
ties outside of your MVC application. Listing 8-21 shows an example of both options.
Listing 8-21.Setting Engine-Specific Properties via the Configurer Bean
<bean id="velocityConfigurer"
class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<bean id="freemarkerConfigurer"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
value="classpath:com/apress/expertspringmvc/fm.properties"/>
CHAPTER 8 ■SUPPORTED VIEW TYPES 239