hi Everyone
Can someone give me a hint why the sample HelloWorld.java (see below) removes
character # from my banner (see MyBanner.vm). As you see, the result shows all
my # signs removed from the first line and second line. Is # a special
character in Velocity? Thanks.
------------------MyBanner.vm ----------------
##########################################
# #
# Hello World - Hello World #
# #
##########################################
------------------- RESULT --------------
# #
# Hello World - Hello World #
# #
-------------------- Program HelloWorld.java
import java.io.StringWriter;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
public class HelloWorld
{
public static void main( String[] args )
throws Exception
{
/* first, get and initialize an engine */
VelocityEngine ve = new VelocityEngine();
ve.init();
/* next, get the Template */
Template t = ve.getTemplate( "MyBanner.vm" );
/* create a context and add data */
VelocityContext context = new VelocityContext();
context.put("name", "World");
/* now render the template into a StringWriter */
StringWriter writer = new StringWriter();
t.merge( context, writer );
/* show the World */
System.out.println( writer.toString() );
}
}