开发者

Working/Include Direct of a Servlet

I'm currently starting to learn to use java to create dynamic website开发者_StackOverflows. I've started using a servlet and the template engine 'velocity'.

My Environement:

WebContent/
   WEB-INF/
      gallery/
         template.file

My Question: I want to use the "template.file" as template. WHAT filename/path do I have to enter to reach my template from a servlet.

Sorry for my bad english :/ It's currently very hot in germany.

Best regards, andre

EDIT: Some Code...

/* Create and setup the Template system */
template = new VelocityEngine();
template.init();
template.getTemplate("template.file"); <--- Waht directory to use


Although WEB-INF/ is on the classpath, you cannot load templates without reconfiguring Velocity. Velocity uses a file-based approach by default. You need to tell Velocity to look on the classpath of the web application, which then uses the ServletContext to load resources packaged within the web application archive.

Please see the Velocity documentation about loading resources in web applications for a detailed description on how to configure Velocity to load templates from within a web application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜