Eclipse 中的动态 Web 模块选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3985916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:42:04  来源:igfitidea点击:

Dynamic Web Module option in Eclipse

eclipsetomcatservletsjakarta-ee

提问by ziggy

Could someone please explain the purpose of this option and what exactly it is for.

有人可以解释一下这个选项的目的以及它到底是做什么的。

It looks like the default is on my eclipse installation is 3.0 but it wont run on a Tomcat 5.5 server and probably not Tomcat 6.0 Is it related to the servlet spec that the Tomcat server supports? If so which version do i need to use for Tomcat 5.5 and Tomcat 6.0?

看起来我的 eclipse 安装的默认值是 3.0,但它不会在 Tomcat 5.5 服务器上运行,也可能不是 Tomcat 6.0 是否与 Tomcat 服务器支持的 servlet 规范有关?如果是这样,我需要为 Tomcat 5.5 和 Tomcat 6.0 使用哪个版本?

And also, i think there is a link between the compiler version that i use and the web module version selected. Is there some kind of documentation that explains what this relationship is?

而且,我认为我使用的编译器版本和选择的 Web 模块版本之间存在链接。是否有某种文件可以解释这种关系是什么?

Edit

编辑

And also, why is it that if i select v2.4 web module, it defaults to JDK 1.4?

而且,为什么如果我选择 v2.4 web 模块,它默认为 JDK 1.4?

Thanks

谢谢

回答by BalusC

That version correlates with Servlet API version. Servlet 3.0(released at december 2009 as part of Java EE 6) runs on Servlet 3.0 containers only (Tomcat 7, Glassfish 3, JBoss AS 6, etc). Servlet 2.5(released at 11 may 2006 as part of Java EE 5) runs on Servlet 2.5 containers only or newer (Tomcat 6, Glassfish 2, JBoss AS 5, etc). Servlet 2.4(released at november 2003 as part of J2EE 1.4) runs on Servlet 2.4 containers only or newer, etcetera.

该版本与 Servlet API 版本相关。Servlet 3.0(2009 年 12 月作为 Java EE 6 的一部分发布)仅在 Servlet 3.0 容器(Tomcat 7、Glassfish 3、JBoss AS 6 等)上运行。Servlet 2.5(2006 年 5 月 11 日作为 Java EE 5 的一部分发布)仅在 Servlet 2.5 容器或更新版本(Tomcat 6、Glassfish 2、JBoss AS 5 等)上运行。Servlet 2.4(2003 年 11 月作为 J2EE 1.4 的一部分发布)仅在 Servlet 2.4 容器或更新的容器上运行,等等。

You just need to pick the right API version whatever you want to implement your webapp in. Or if you don't have the freedom in picking the servlet container used, then pick the API which suits the servlet container version the best.

您只需要选择正确的 API 版本来实现您的 web 应用程序。或者,如果您没有自由选择使用的 servlet 容器,那么选择最适合 servlet 容器版本的 API。

As to why the JDK defaults to one or other, it's just the minimum JDK requirement of the Servlet API version in question. Often, when you're picking an older Servlet API, in reality the JRE/JDK used is also that old.

至于为什么 JDK 默认为一种或另一种,这只是所讨论的 Servlet API 版本的最低 JDK 要求。通常,当您选择较旧的 Servlet API 时,实际上使用的 JRE/JDK 也很旧。

回答by Sai Kiran

The below are the jdk requirement for servlet API.

以下是 servlet API 的 jdk 要求。

Please find the compatibilty.

请找出兼容性。

Servlet 4.0     Java EE 8   

Servlet 3.1     Java EE 7   

Servlet 3.0     Java EE 6, Java SE 6

Servlet 2.5     Java EE 5, Java SE 5

Servlet 2.4     J2EE 1.4, J2SE 1.3  

Servlet 2.3     J2EE 1.3, J2SE 1.2  

Servlet 2.2     J2EE 1.2, J2SE 1.2  

I think this will helpful for you.. :)

我认为这对你有帮助.. :)

Thanks

谢谢