When loading Velocity template with the default setting.
The following exception might be hit
Even I used the Class Resource Loader, still hitting the same exception.
The exception solved when used File Resource Loader together with the system Real Path.
p/s: assuming all .vm files are kept under <webapp>/WEB-INF/mytemplatepath folder.
Done!!
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource
Even I used the Class Resource Loader, still hitting the same exception.
The exception solved when used File Resource Loader together with the system Real Path.
String myTemplatePath = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/WEB-INF/mytemplatepath");
Properties p = new Properties();
p.setProperty( "file.resource.loader.path", myTemplatePath);
Velocity.init(p);
Template template = Velocity.getTemplate( "mytemplate1.vm" );
p/s: assuming all .vm files are kept under <webapp>/WEB-INF/mytemplatepath folder.
Done!!
No comments:
Post a Comment