Knowledge Walls
John Peter
Pune, Maharashtra, India
How to use Single line and Multiline Comment in Java apache velocity with Example
20624 Views
Single and Multiline Comment in Velocity 
## single line comment here

#*
Multiline comment here
Line1
Line2
*#
CommentInVelocityExample
import java.io.StringWriter;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;

public class CommentInVelocityExample {
    public static void main(String args[]){
        VelocityEngine engine = new VelocityEngine();
        engine.init();
        
        Template template = engine.getTemplate("velocitytemplate.vm");
        
        VelocityContext context = new VelocityContext();
            context.put("a", 10);
            context.put("b", 20);
            
        StringWriter sw = new StringWriter();
        template.merge(context, sw);
        
        System.out.println(sw.toString());
    }
}
Velocitytemplate.vm 
## Adding a and b values
C = a + b
#set($c=$a+$b)
C = $c
Output 
C = a + b
C = 30
Best Lessons of "Java Apache Velocity Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details