Announcement Announcement Module
Collapse
No announcement yet.
freemarker macro usage question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • freemarker macro usage question

    Hi I'm following the example in the docs talking about the spring macros. I have a fairly straight forward question in regards to the use of the macros.

    I'm trying to use the URL macro. From what I can tell from the documentation this should be valid. However I'm getting the following error below:

    btw. I'm running freemarker 2.3.2 with spring 1.1.5 with tomcat 5.0.28.


    ~~~~~~~~~~~~~~~~~~~~~~

    code snippet

    <#import "spring.ftl" as spring />
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <title>User Login</title>
    <link href="<@spring.url stylesheet.css/>" rel="stylesheet" type="text/css">
    </head>
    ......

    ~~~~~~~~~~~~~~~~~~~~~~~

    Errror

    macro url [on line 43, column 1 in spring.ftl] in user-directive spring.url [on line 7, column 19 in index.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression stylesheet is undefined on line 7, column 32 in index.ftl. at freemarker.core.TemplateObject.assertNonNull(Templ ateObject.java:124) at freemarker.core.TemplateObject.invalidTypeExceptio n(TemplateObject.java:134) at freemarker.core.Dot._getAsTemplateModel(Dot.java:7 8) at freemarker.core.Expression.getAsTemplateModel(Expr ession.java:89) at freemarker.core.Environment.visit(Environment.java :514) at freemarker.core.UnifiedCall.accept(UnifiedCall.jav a:128) at freemarker.core.Environment.visit(Environment.java :196) at freemarker.core.MixedContent.accept(MixedContent.j ava:92) at freemarker.core.Environment.visit(Environment.java :196) at freemarker.core.Environment.process(Environment.ja va:176) at freemarker.template.Template.process(Template.java :231) at org.springframework.web.servlet.view.freemarker.Fr eeMarkerView.processTemplate(FreeMarkerView.java:2 67) at org.springframework.web.servlet.view.freemarker.Fr eeMarkerView.doRender(FreeMarkerView.java:221) at org.springframework.web.servlet.view.freemarker.Fr eeMarkerView.renderMergedTemplateModel(FreeMarkerV iew.java:180) at org.springframework.web.servlet.view.AbstractTempl ateView.renderMergedOutputModel(AbstractTemplateVi ew.java:160) at org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:917) at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:696) at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:623) at org.springframework.web.servlet.FrameworkServlet.s erviceWrapper(FrameworkServlet.java:384) at org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:344) at javax.servlet.http.HttpServlet.service(HttpServlet .java:689) at javax.servlet.http.HttpServlet.service(HttpServlet .java:802) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157) at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362) at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186) at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534)

  • #2
    Re: freemarker macro usage question

    Well I figured it out. Forgot to put "" around the argument to the macro.

    ~~~~~~~~~~~~~~~~~~~~~~

    code snippet

    <#import "spring.ftl" as spring />
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <title>User Login</title>
    <link href="<@spring.url "/stylesheet.css"/>" rel="stylesheet" type="text/css"> <---------
    </head>
    ......

    ~~~~~~~~~~~~~~~~~~~~~~~

    Comment

    Working...
    X