title: Adding spring library for usage of JSP Taglibs for security in Freemarker
body: <p>I am using spring with freemarker as the template engine. Freemarker allows to use the Jsp Taglibs, for security for example, by adding</p>
  
  <pre><code>    &lt;#assign security=JspTaglibs["http://www.springframework.org/security/tags"] /&gt;
  </code></pre>
  
  <p>to the templates, what allows me to use for example </p>
  
  <pre><code>    &lt;@security.authorize ifNotGranted="ROLE_ADMIN"&gt;
          whatever
      &lt;/@security.authorize&gt;
  </code></pre>
  
  <p>But, Spring/Freemarker cannot find the taglibs, unless they are added to the classpath, so I added </p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
          &lt;artifactId&gt;spring-security-taglibs&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>to my pom.xml in my project. </p>
  
  <p>But anyway, the tags couldn't be found! I had to add the spring-security-taglibs.jar into WEB-INF/lib folder for the tags to be found. </p>
  
  <p>Does someone know why the jar has to be added explicitly into the lib folder?? Why aren't they found by tomcat, in my case?</p>
  
  <p>EDIT @ddekany</p>
  
  <p>Thank you. The stacktrace is the following, if the spring-security-taglibs.jar is not copied into the WEB-INF/lib directory</p>
  
  <pre><code>    No mapping defined for http://www.springframework.org/security/tags 
      The problematic instruction: ---------- ==&gt; assignment: 
              security=JspTaglibs["http://www.springframework.org/security/tags"] 
              [on line 12, column 1 in home.ftl] in user-directive content.main 
              [on line 8, column 9 in home.ftl] in user-directive layout.global 
              [on line 2, column 1 in home.ftl] 
      ---------- Java backtrace for programmers: ----------      
      freemarker.template.TemplateModelException: 
              No mapping defined for http://www.springframework.org/security/tags at         
      freemarker.ext.jsp.TaglibFactory.get(TaglibFactory.java:180) at 
      ...
  </code></pre>