Exception occurred:
org.apache.velocity.exception.ResourceNotFoundException: Unable to
find resource ‘ResourceLoader1.vm’
I am having ResourceLoader1.vm in /WEB-INF/templates, I stuck up with this please help me.
Properties props = new Properties();
props.put("file.resource.loader.path", "/WEB-INF/templates");
Velocity.init(props);
VelocityContext context = new VelocityContext();
context.put("greetings", "Many Happy returns");
context.put("name", "Joseph");
Writer writer = new StringWriter();
Template template = Velocity.getTemplate("ResourceLoader1.vm");
template.merge(context, writer);
You should put .vm templates relative to the CLASSPATH. A better choice would be to put the /templates directory under WEB-INF/classes, lose the props, and fetch it like this: