在 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 theMETA-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/