■NoteCheck the relevant Velocity and FreeMarker documentation at their respective websites to see the
range of properties and settings that can be configured on the two engines.
By default, Spring doesn’t expose request or session attributes to your template engines. If
you want to access those values in your templates, you need to tell Spring to make them avail-
able. This is the same mechanism for both Velocity and FreeMarker, as the relevant properties
are part of a common superclass (shown in Figure 8-4).
Figure 8-4.AbstractTemplateView detail
Listing 8-22 has an example of exposing request and session attributes for a VelocityView
instance.
Listing 8-22.Exposing Session and Request Attributes on a View
attributeView.class=org.springframework.web.servlet.view.velocity.VelocityView
attributeView.exposeRequestAttributes=true
attributeView.exposeSessionAttributes=true
AbstractTemplateView
+ SPRING MACRO REQUEST CONTEXT ATTRIBUTE : String
- exposeRequestAttributes : boolean
- exposeSessionAttributes : boolean
- exposeSpringMacroHelpers : boolean
- allowRequestOverride : boolean
- allowSessionOverride : boolean
- setExposeRequestAttributes(exposeRequestAttributes : boolean)
- setExposeSessionAttributes(exposeSessionAttributes : boolean)
- setAllowRequestOverride(allowRequestOverride : boolean)
- setAllowSessionOverride(allowSessionOverride : boolean)
- setExposeSpringMacroHelpers(exposeSpringMacroHelpers : boolean)
renderMergedOutputModel(model : Map, request : , response : HttpServletResponse)
renderMergedTemplateModel(model : Map, request : , response : HttpServletResponse)
FreeMarkerView VelocityView
240 CHAPTER 8 ■SUPPORTED VIEW TYPES