9
I am using spring with freemarker as the template engine. Freemarker allows to use the Jsp Taglibs, for security for example, by adding
<#assign security=JspTaglibs["http://www.springframework.org/security/tags"] />
to the templates, what allows me to use for example
<@security.authorize ifNotGranted="ROLE_ADMIN">
whatever
</@security.authorize>
But, Spring/Freemarker cannot find the taglibs, unless they are added to the classpath, so I added
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${spring.version}</version>
</dependency>
to my pom.xml in my project.
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.
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?
EDIT @ddekany
Thank you. The stacktrace is the following, if the spring-security-taglibs.jar is not copied into the WEB-INF/lib directory
No mapping defined for http://www.springframework.org/security/tags
The problematic instruction: ---------- ==> 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