Package org.apache.velocity.spring
Class VelocityEngineUtils
- java.lang.Object
-
- org.apache.velocity.spring.VelocityEngineUtils
-
public abstract class VelocityEngineUtils extends Object
Utility class for working with a VelocityEngine. Provides convenience methods to merge a Velocity template with a model.- Since:
- 2020-05-29
- Author:
- Juergen Hoeller, Claude Brisson
-
-
Constructor Summary
Constructors Constructor Description VelocityEngineUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
mergeTemplate(VelocityEngine velocityEngine, String templateLocation, String encoding, Map<String,Object> 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, Map<String,Object> model, Writer writer)
Deprecated.UsemergeTemplate(VelocityEngine, String, String, Map, Writer)
instead, following Velocity 1.6's corresponding deprecation in its own API.static String
mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, String encoding, Map<String,Object> model)
Merge the specified Velocity template with the given model into a String.static String
mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, Map<String,Object> model)
Deprecated.UsemergeTemplateIntoString(VelocityEngine, String, String, Map)
instead, following Velocity 1.6's corresponding deprecation in its own API.
-
-
-
Method Detail
-
mergeTemplate
@Deprecated public static void mergeTemplate(VelocityEngine velocityEngine, String templateLocation, Map<String,Object> model, Writer writer) throws VelocityException
Deprecated.UsemergeTemplate(VelocityEngine, String, String, Map, Writer)
instead, following Velocity 1.6's corresponding deprecation in its own API.Merge the specified Velocity template with the given model and write the result to the given Writer.- Parameters:
velocityEngine
- VelocityEngine to work withtemplateLocation
- the location of template, relative to Velocity's resource loader pathmodel
- the Map that contains model names as keys and model objects as valueswriter
- the Writer to write the result to- Throws:
VelocityException
- if the template wasn't found or rendering failed
-
mergeTemplate
public static void mergeTemplate(VelocityEngine velocityEngine, String templateLocation, String encoding, Map<String,Object> model, Writer writer) throws VelocityException
Merge the specified Velocity template with the given model and write the result to the given Writer.- Parameters:
velocityEngine
- VelocityEngine to work withtemplateLocation
- the location of template, relative to Velocity's resource loader pathencoding
- the encoding of the template filemodel
- the Map that contains model names as keys and model objects as valueswriter
- the Writer to write the result to- Throws:
VelocityException
- if the template wasn't found or rendering failed
-
mergeTemplateIntoString
@Deprecated public static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, Map<String,Object> model) throws VelocityException
Deprecated.UsemergeTemplateIntoString(VelocityEngine, String, String, Map)
instead, following Velocity 1.6's corresponding deprecation in its own API.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 withtemplateLocation
- the location of template, relative to Velocity's resource loader pathmodel
- the Map that contains model names as keys and model objects as values- Returns:
- the result as String
- Throws:
VelocityException
- if the template wasn't found or rendering failed- See Also:
org.springframework.mail.MailPreparationException
-
mergeTemplateIntoString
public static String mergeTemplateIntoString(VelocityEngine velocityEngine, String templateLocation, String encoding, Map<String,Object> model) throws VelocityException
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 withtemplateLocation
- the location of template, relative to Velocity's resource loader pathencoding
- the encoding of the template filemodel
- the Map that contains model names as keys and model objects as values- Returns:
- the result as String
- Throws:
VelocityException
- if the template wasn't found or rendering failed- See Also:
org.springframework.mail.MailPreparationException
-
-