In Java EE application Development, the velocity template files are often packaged together in a jar file, but velocity's default behavior is to read the template file from the OS file system and use Fileresourceloader to read the template file.
If you want to get the template file from Classpath instead, adjust the velocity initialization parameters:
Velocityengine ve=new velocityengine ();
Optional value: "Class"-read from Classpath, "file"-read from the file system
Ve.setproperty ("Resource.loader", "class");
If the template is read from the file system, then the property value is Org.apache.velocity.runtime.resource.loader.FileResourceLoader
Ve.setproperty ("Class.resource.loader.class", " Org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ");
Ve.init ();
Template t=ve.gettemplate ("/VMPATH/TEST.VM");
In addition, velocity defaults provide a variety of ways to read templates, listed below, which can refer to Javadoc in the release package:
Org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader
Org.apache.velocity.runtime.resource.loader.JarResourceLoader
Org.apache.velocity.runtime.resource.loader.StringResourceLoader
Org.apache.velocity.runtime.resource.loader.URLResourceLoader