How to pass java.util.Properties in properties
This Example shows you how to use java.util.Properties to in velocity. The methods used in this example are described below:-1:- Initialize velocity run time engine through method init().
2:- Create object of VelocityContext Class.
3:- Create Template class object, Template class object is used for controlling template methods and properties.
In this example we have used method init() with parameter of type Properties type that initialize velocity runtime engine with default properties plus properties passed as parameter in init() method.
template.merge(context, writer): Merge method of the Template class is used here for merging the VelocityContext class object to produce the output.
PassProperties.java
import java.io.StringWriter;
|
PassProperties.vm
Hi,this is Komal Choudhary |
Output:
Hi,this is Komal Choudhary |
Download code