Hi Vanessa,

It looks to me that you are relying on the default way that Velocity
loads its templates. I am not sure if it is loading from classpath?

But, typically I would use more explicit way to load templates, for
example, just use the file system path like this:

File templateDir = new File("/path/to/template");
ve = new VelocityEngine();
// setting up file resource loader
ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
templateDir.getCanonicalPath());

This way, you have total control and know where to load the templates.
As for the output, it is as simple as:

OutputStreamWriter out = new
OutputStreamWriter(response.getOutputStream(), "UTF-8");
ve.mergeTemplate(viewName + ".html", "UTF-8", ctx, out);
if (flushOutput)
{
        out.flush();
}

This is pretty much how I am using Velocity right now. Hope it helps.


Jian
http://www.JiansNet.com
Useful Info on Living In USA, Powered By Velocity

On Sat, May 26, 2012 at 9:13 AM, vanessa vanessa
<vanessa032...@gmail.com> wrote:
> Hi all ,
>
> I'm using velocity in a plug-in projet.In the root of my plugin
> i put a folder templates/template.vm. And i call the template
> velocity.getTemplate(template.vm) from my class.
> But the resource is not found i don't no why its directory isn't
> recognised.the template cannot be loaded.
>
> Every thing work fine in a java-Project.
>  I will appreciate any help.
> Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to