Call class methods
This Example shows you how to call class method in velocity template.Steps used in the code given below :
1: Initialize velocity through method init().
2: Create object of VelocityContext Class.
3: Use put() method of Class VelocityContext through object 'ctx'.
4: Create the object of java.util.Date class
5: Set into velocity context
6: Then use this (Date) object in velocity template.
CallClassMethods.java
package velocity.ClassReference; |
ClassMethods.vm
Day: $date.getDate()
|
Output :
Day: 23 |