Java Mailing List Archive

http://www.junlu.com/

Home » FreeMarker-user »

Re: [FreeMarker-user] simple layout not working

Daniel Dekany

2012-03-28

Replies: Find Java Web Hosting

Author LoginPost Reply
Wednesday, March 28, 2012, 4:43:02 AM, S Ahmed wrote:

> I'm getting this error:
>
> Error reading imported file WEB-INF/views/layout/master.ftl The
> problematic instruction: ---------- ==> import
> "/WEB-INF/views/layout/master.ftl" as p [on line 1, column 1 in
> home/index.ftl] ---------- Java backtrace for programmers:
> ---------- freemarker.template.TemplateException: Error reading
> imported file WEB-INF/views/layout/master.ftl at
> freemarker.core.LibraryLoad.accept (LibraryLoad.java:122) at
> freemarker.core.Environment.visit (Environment.java:221) at
> freemarker.core.MixedContent.accept (MixedContent.java:92) at
> freemarker.core.Environment.visit (Environment.java:221) at
> freemarker.core.Environment.process (Environment.java:199) at
> freemarker.template.Template.process (Template.java:259) at
> org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate (FreeMarkerView.java:366)
> at
> org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender (FreeMarkerView.java:283)
> at
> org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel (FreeMarkerView.java:233)
> at
> org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel (AbstractTemplateView.java:167)
> at
> org.springframework.web.servlet.view.AbstractView.render (AbstractView.java:262)
> at
> org.springframework.web.servlet.DispatcherServlet.render (DispatcherServlet.java:1157) at

There should be a "Caused by:" part as well. I suppose it says
java.io.FileNotFoundException.

> My 2 templates are in:
>
> /web-inf/views/layout/master.ftl
> /web-inf/views/home/index.ftl
>
>
> index.ftl:
>
> <#import "/WEB-INF/views/layout/master.ftl" as p>

>From the error message it seems that your template root directory is
/WEB-INF/views. So it should be <#import "/layout/master.ftl" as p>.

> <@(protected)">
>   nested goes here
> </@(protected)>
>
>
> master.ftl:
>
> <#escape x as x?html>
>
>   <#macro page title>
>   <!DOCTYPE html>
>
>   <html>
>   <head>
>      <meta http-equiv="content-type"
> content="text/html;charset=utf-8"/>
>      <title>${title}</title>
> ...
> ..
> <#nested>
> ..
> ..
>
>   </body>
>   </html>
>   </#macro>
> </#escape>
>
>
> Does anything seem wrong here?

--
Best regards,
Daniel Dekany


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
FreeMarker-user mailing list
FreeMarker-user@(protected)
https://lists.sourceforge.net/lists/listinfo/freemarker-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.