instagram

Apache Velocity Part 7 – Context

In Apache velocity, There are three main ways to pass data from Java class to VM template.

1. Key and Value mapping
2. Key and Bean/POJO (Object) mapping
3. Key and Inner Map mapping

Lets see each and every mapping with example.

1. Key and Value mapping


This is normal key and value in VelocityContext. Find below VM and Code for example.

context.vm

Java Example :

2. Key and Bean/POJO (Object) mapping


beancontext.vm

Customer.java

Java Example :

3. Key and Inner Map mapping


innermapcontext.vm

Java Example :

Share