JSP Tags in Freemarker Template

I want to use some custom tags in the freemarker template, which is quite simple since I can include JspSupportServlet in my web.xml file and include the following line in the template.

<#assign my=JspTaglibs["/WEB-INF/mytaglib.tld"] /> 

How can I do this if the .tld comes in a JAR file inside the META-INF directory? I tried both of them with no luck.

 <#assign my=JspTaglibs["/META-INF/mytaglib.tld"] /> <#assign my=JspTaglibs["/mynamespace"] /> 
+6
source share
1 answer

FreeMarker automatically scans all the JAR files in your WEB-INF / lib directory. If he finds .tld files in the JAR META-INF directory, like your META-INF / mytaglib.tld, he will look inside to find the <uri> . If he finds one, he will make taglib accessible through this URI, for example taglib defined as

 <taglib> <shortname>my custom taglib</shortname> <uri>http://example.org/mytaglib</uri> <!-- ... --> </taglib> 

can be used in freemarker through

 <#assign my=JspTaglibs["http://example.org/mytaglib"] /> 

At least it worked for me ...

+3
source

Source: https://habr.com/ru/post/894924/


All Articles