我如何知道我拥有的 servlet-api.jar 版本是什么?

发布于 2024-09-27 01:51:52 字数 314 浏览 2 评论 0原文

我从 java2s.com 下载了 servlet-api.jar 的副本。我怎么知道它是什么版本?网站上没有任何参考。

编辑

啊。抱歉。当我双击我得到的 jar 中的 MANIFEST.MF 文件时,我应该列出写字板输出的内容:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)

如您所见,它没有告诉我版本,因此出现了问题。

I downloaded a copy of servlet-api.jar from java2s.com. How do I know what version it is? There's no reference on the site.

EDIT

Ah. Apologies. I should have listed the content of the wordpad output when I double clicked on the MANIFEST.MF file in the jar I got:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)

As you can see it didnt tell me the version hence the question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

萤火眠眠 2024-10-04 01:51:52

使用下面的代码片段:

<%= session.getServletContext().getMajorVersion() %>.
<%= session.getServletContext().getMinorVersion() %>

use the below code snippet :

<%= session.getServletContext().getMajorVersion() %>.
<%= session.getServletContext().getMinorVersion() %>
纵山崖 2024-10-04 01:51:52

你可以从 META-INF 获取它,你可以使用 win rar 或类似的归档工具来探索 jar 文件的内容。

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4  

我个人更喜欢从 maven repo 下载 jar。

you can get it from META-INF, you can explore the content of jar file using win rar or such archiving utils something like.

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4  

I personally prefer maven repo to download jar from.

染柒℉ 2024-10-04 01:51:52

您可以使用 tomcat 附带的版本 2.4 的清单从 jar 文件的 META-INF 目录中提取 MANIFEST.MF,

jar xf servlet-api.jar META-INF/MANIFEST.MF

如下所示

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 2.4.public_draft
Implementation-Vendor: Apache Software Foundation

you can extract the MANIFEST.MF from the META-INF directory of your jar file by using

jar xf servlet-api.jar META-INF/MANIFEST.MF

the manifest for version 2.4 that comes with tomcat looks like this for example

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 2.4
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 2.4.public_draft
Implementation-Vendor: Apache Software Foundation
白首有我共你 2024-10-04 01:51:52

它基本上位于 /META-INF/MANIFEST.MF 下 JAR 的 MANIFEST 文件内:

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 3.0
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 3.0.FR
Implementation-Vendor: Apache Software Foundation

It's basically inside your JAR's MANIFEST file under /META-INF/MANIFEST.MF:

Name: javax/servlet/
Specification-Title: Java API for Servlets
Specification-Version: 3.0
Specification-Vendor: Sun Microsystems, Inc.
Implementation-Title: javax.servlet
Implementation-Version: 3.0.FR
Implementation-Vendor: Apache Software Foundation
翻身的咸鱼 2024-10-04 01:51:52

对于关注者来说,如果它在 jnlp 发行版中,可能会有一个附带的“version.xml”文件,告诉您每个 jar 分别是什么版本。

for followers, if it's in a jnlp distro, there may be an accompanying "version.xml" file that tells you what versions each jar is respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文