且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Freemarker模板中的JSP标记

更新时间:2023-11-19 18:28:22

FreeMarker会自动扫描WEB-INF中的所有JAR文件/ lib目录。如果它在JAR的META-INF目录中找到.tld文件,就像你的META-INF / mytaglib.tld一样,它会在里面查看,以便找到< uri> 标签。如果找到一个,它将通过此​​URI使taglib可用,例如定义为

FreeMarker automatically scans all JAR files in your WEB-INF/lib directory. If it finds .tld files inside a JAR's META-INF directory, like your META-INF/mytaglib.tld, it will peek inside it in order to find the <uri> tag. If it finds one, it will make the taglib available via this URI, e.g a taglib defined like

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

可以在FreeMarker中使用

can be used in FreeMarker via

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

至少这对我有用...

At least this worked for me...