instagram

Apache Velocity Part 8 – Properties

You can store, access and modify properties available in Velocity class.

Velocity has its own default properties available at below path.

"org/apache/velocity/runtime/defaults/velocity.properties"

You can access those properties and modify them as per below.

Access Properties :

Modify Default Properties :

Add Additional Properties :

This is little tricky you can not use java.util.Properties class directly to add new properties in Velocity class. Here you mush have to use org.apache.commons.collections.ExtendedProperties; class to add new custom properties.

Lets see below example. It is very simple but you just have to take care of adding ExtendedProperties object in Velocity class BEFORE calling init() method.

Share