gpt4 book ai didi

java - web.xml 如何知道特定 jar 中存在的 servlet

转载 作者:太空宇宙 更新时间:2023-11-04 13:31:51 25 4
gpt4 key购买 nike

我正在使用 Web 应用程序,其中 jar 文件位于 lib 文件夹中。在web.xml中,提供了servlet类。web.xml如何知道该特定类在哪个jar文件中???

最佳答案

这是由类加载器机制处理的:

A JAR file usually contains a "manifest" -- a file which lists the contents of the JAR. The manifest can define a JAR-class-path, which further extends the class path (but only while loading classes from that JAR). Classes accessed by a JAR-class-path are found in the following order:

In general, classes referenced by a JAR-class-path entry are found as though they were part of the JAR file. The JAR files that appear in the JAR-class-path are searched after any earlier class path entries, and before any entries that appear later in the class path. However, if the JAR-class-path points to a JAR file that was already searched (for example, an extension, or a JAR file that was listed earlier in the class path) then that JAR file will not be searched again. (This optimization improves efficiency and prevents circular searches.) Such a JAR file is searched at the point that it appears, earlier in the class path. If a JAR file is installed as an extension, then any JAR-class-path it defines is ignored. All the classes required by an extension are presumed to be part of the SDK or to have themselves been installed as extensions.

source

关于java - web.xml 如何知道特定 jar 中存在的 servlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32110702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com