Apache Velocity is a Java-based template engine. It can be used to dynamically generate web pages, email messages, source code, or any other text file.
Apache Velocity is a Java-based template engine. It can be used to dynamically generate web pages, email messages, source code, or any other text file.
Apache Velocity is a project of the Apache Software Foundations (ASF).
More information is available at the project home page: http://velocity.apache.org.
From the developer perspective, the fundamental pattern for rendering a text file is:
- Create and initialize a VelocityEngine.
- Add your data objects to a Context (essentially, a map of objects available for use in the template)
- Choose a template
- Merge the template with the context.
This can be done in a few lines of Java code, or you can use one of several frameworks to integrate this with your application.
One of the most popular web application frameworks which integrates Velocity is the Spring Framework. For simple servlet based applications, most developers use one of the Velocity Tools servlets (also available from the Apache Velocity project).
Useful Online Resources
- Velocity User Guide
- Velocity Developer Guide