public abstract class

VelocityEngineUtils

extends Object
java.lang.Object
   ↳ org.springframework.ui.velocity.VelocityEngineUtils

Class Overview

Utility class for working with a VelocityEngine. Provides convenience methods to merge a Velocity template with a model.

Summary

Public Constructors
VelocityEngineUtils()
Public Methods
static void mergeTemplate(VelocityEngine velocityEngine, String templateLocation, Map model, Writer writer)
Merge the specified Velocity template with the given model and write the result to the given Writer.
static void mergeTemplate(VelocityEngine velocityEngine, String templateLocation, String encoding, Map model, Writer writer)
Merge the specified Velocity template with the given model and write the result to the given Writer.
static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, String encoding, Map model)
Merge the specified Velocity template with the given model into a String.
static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, Map model)
Merge the specified Velocity template with the given model into a String.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public VelocityEngineUtils ()

Public Methods

public static void mergeTemplate (VelocityEngine velocityEngine, String templateLocation, Map model, Writer writer)

Merge the specified Velocity template with the given model and write the result to the given Writer.

Parameters
velocityEngine VelocityEngine to work with
templateLocation the location of template, relative to Velocity's resource loader path
model the Map that contains model names as keys and model objects as values
writer the Writer to write the result to
Throws
if the template wasn't found or rendering failed
VelocityException

public static void mergeTemplate (VelocityEngine velocityEngine, String templateLocation, String encoding, Map model, Writer writer)

Merge the specified Velocity template with the given model and write the result to the given Writer.

Parameters
velocityEngine VelocityEngine to work with
templateLocation the location of template, relative to Velocity's resource loader path
encoding the encoding of the template file
model the Map that contains model names as keys and model objects as values
writer the Writer to write the result to
Throws
if the template wasn't found or rendering failed
VelocityException

public static String mergeTemplateIntoString (VelocityEngine velocityEngine, String templateLocation, String encoding, Map model)

Merge the specified Velocity template with the given model into a String.

When using this method to prepare a text for a mail to be sent with Spring's mail support, consider wrapping VelocityException in MailPreparationException.

Parameters
velocityEngine VelocityEngine to work with
templateLocation the location of template, relative to Velocity's resource loader path
encoding the encoding of the template file
model the Map that contains model names as keys and model objects as values
Returns
  • the result as String
Throws
if the template wasn't found or rendering failed
VelocityException

public static String mergeTemplateIntoString (VelocityEngine velocityEngine, String templateLocation, Map model)

Merge the specified Velocity template with the given model into a String.

When using this method to prepare a text for a mail to be sent with Spring's mail support, consider wrapping VelocityException in MailPreparationException.

Parameters
velocityEngine VelocityEngine to work with
templateLocation the location of template, relative to Velocity's resource loader path
model the Map that contains model names as keys and model objects as values
Returns
  • the result as String
Throws
if the template wasn't found or rendering failed
VelocityException