jsf-2 - 在 jsf-impl.jar 中发现了 JSF2 : How are the *. taglib.xml 文件?

标签 jsf-2 facelets taglib

jsf-impl.jar (可以在 mvnrepository.com 上找到),*.taglib.xml文件位于目录 com/sun/faces/metadata/taglib/ .

我不明白在这种情况下它们是如何被发现的,因为 JSF 2 specification 的第 10.3.2 章说:

10.3.2 Facelet Tag Library mechanism

...

The run time must support two modes of discovery for Facelet tag library descriptors

  • Via declaration in the web.xml, as specified in Section 11.1.3 “Application Configuration Parameters”

  • Via auto discovery by placing the tag library descriptor file within a jar on the web application classpath, naming the file so that it ends with “.taglib.xml”, without the quotes, and placing the file in the META-INF directory in the jar file.

...



在这里,它们不在目录 META-INF 中。 , 那么它是怎样工作的?

注意:在 META-INF ,他们是一些.tld文件,但我对它们不感兴趣,因为我没有使用 JSP 作为 View ,而是使用 Facelets。

最佳答案

它没有使用 taglib.xml为了那个原因。它通过 com.sun.faces.facelets.tag.jsf.html.HtmlLibrary 以编程方式注册它们在 com.sun.faces.application.ApplicationAssociate 它在启动期间执行。以下是 Mojarra 2.2.1 中的相关行(从 Grepcode 复制粘贴):

954        c.addTagLibrary(new CoreLibrary());
955        c.addTagLibrary(new CoreLibrary(CoreLibrary.XMLNSNamespace));
956        c.addTagLibrary(new HtmlLibrary());
957        c.addTagLibrary(new HtmlLibrary(HtmlLibrary.XMLNSNamespace));
958        c.addTagLibrary(new UILibrary());
959        c.addTagLibrary(new UILibrary(UILibrary.XMLNSNamespace));
960        c.addTagLibrary(new JstlCoreLibrary());
961        c.addTagLibrary(new JstlCoreLibrary(JstlCoreLibrary.IncorrectNamespace));
962        c.addTagLibrary(new JstlCoreLibrary(JstlCoreLibrary.XMLNSNamespace));
963        c.addTagLibrary(new PassThroughAttributeLibrary());
964        c.addTagLibrary(new PassThroughElementLibrary());
965        c.addTagLibrary(new FunctionLibrary(JstlFunction.class, FunctionLibrary.Namespace));
966        c.addTagLibrary(new FunctionLibrary(JstlFunction.class, FunctionLibrary.XMLNSNamespace));
967        if (isDevModeEnabled()) {
968            c.addTagLibrary(new FunctionLibrary(DevTools.class, DevTools.Namespace));
969            c.addTagLibrary(new FunctionLibrary(DevTools.class, DevTools.NewNamespace));
970        }
971        c.addTagLibrary(new CompositeLibrary());
972        c.addTagLibrary(new CompositeLibrary(CompositeLibrary.XMLNSNamespace));

关于jsf-2 - 在 jsf-impl.jar 中发现了 JSF2 : How are the *. taglib.xml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19027595/

相关文章:

java - 托管 Bean - 仅在页面加载时执行代码

jsf - Facelets 中的 For 循环等效项

java - 在 Struts 1 表单中显示列表

grails - Grails Groovy代码内部值

java - Maven 依赖项 jar 中的 Taglib。我如何在 web.xml 中配置这个 taglib?

jsf-2 - 如何在Primefaces中显示带有html标记的文本

ajax - JSF 和 Ajax 验证 - 如何更新所有消息的消息面板?

java - 使用 JSF 添加动态内容

jsf - primefaces 文件上传无效的文件类型 doc, docx

java - JSF 2.0 - bean 作用域的可能性