title: Send Spring model to Freemarker head tag with no specific route
body: <p>I'm having a problem with sending from Spring to Freemarker. I'm using a service where I need to get script from calling a method and put the script in head tag. I'm using the same header.ftl for all the pages. That is, my head.ftl is something like:</p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
     // head content
  &lt;/head&gt;
  &lt;body&gt; // But no close tag for body.
  </code></pre>
  <p>In other ftl, I will do:</p>
  <pre><code>&lt;#include &quot;header.ftl&quot;&gt;
  // then continue with body content
  </code></pre>
  <p>This is what I'm doing:</p>
  <p>In the UI controller that handles multiple RequestMappings, I add:</p>
  <pre><code>@ModelAttribute(&quot;client&quot;)
  public Client getTheClient() {
      return new Client();
  }
  </code></pre>
  <p>Other methods in this UI controller are mostly:</p>
  <pre><code>@RequestMapping(value=&quot;/apple&quot;)
  public void apple(HttpServletRequest req, HttpServletResponse res) {
    // bind the page with a &quot;apple.ftl&quot; templage
  }
  </code></pre>
  <p>In the head tag, I do:</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;${client.getScript()}&lt;/script&gt;
  </code></pre>
  <p>But it cannot find &quot;client&quot;. (Says undefined or something)
  Then I add</p>
  <pre><code>&lt;#import &quot;/spring.ftl as spring&quot;&gt;
  &lt;@spring.bind &quot;client&quot;&gt;
  </code></pre>
  <p>before the script, now it says &quot;Error reading imported spring.ftl&quot;. (I don't know where is spring.ftl either. I just follow other posts on the internet.)</p>
  <p>Other posts are talking about giving a specific route to RequestMapping, and mostly uses jsp for frontend. But in my case it's different.</p>
  <p>Can anyone help? I really appreciate it!!!</p>