"javax.servlet.http.HttpServlet" 未在 Java 构建路径中找到
"javax.servlet.http.HttpServlet" was not found on the Java Build Path
我只是想学习一些东西 JSP 但我反复遇到该错误。我已经尝试了互联网上的所有内容,但没有任何反应。我正在使用 Tomcat v10 和 JDK15.0.2。当我创建一个新的 JSP 文件时会发生此错误。
您需要 https://download.eclipse.org/releases/2021-03/ 的更新。对 Apache Tomcat 10 和 Jakarta EE JSP 的支持非常新。
我想你也可以使用 Tomcat 9.
Java EE ⇝ Jakarta EE
阅读 front page of downloading documentation for Apache Tomcat 10. 引用:
Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later.
并阅读 first page of the main documentation for Apache Tomcat 10. 引用:
Apache Tomcat version 10.0 implements the Servlet 5.0 and JavaServer Pages 3.0 specifications from Jakarta EE …
作为 Oracle 将所谓的 Java EE(企业版)的责任移交给 Eclipse 基金会的一部分,Jakarta EE are changing from javax.*
to jakarta.*
. You can read about this on the Tomcat page, Which version? — Apache Tomcat Versions, and on the internet.
中的包名称
- Tomcat 10 is for people moving forward to Jakarta EE versions 9 and later, using the
jakarta.*
namespace with the latest Servlet & JSP specs.
- Tomcat 9 is for people sticking with the
javax.*
namespace using the popular Servlet 4 规范和相关 API。
如果您想使用最新的 API,请将 import
语句更改为使用 jakarta.
而不是 javax.
。或者将 Tomcat 10 换成 Tomcat 9 以使用旧的 javax.
命名空间。
- 如果您正在学习和试验,我建议使用
jakarta.
命名空间以及 Tomcat 10.
- 如果您正在使用尚未更新到
jakarta.
命名空间的重要库或工具,请坚持使用旧 API 和 Tomcat 9.
有人讨论了通过自动化某些命名空间切换来提供帮助的工具。但是不知道那里的情况。
我只是想学习一些东西 JSP 但我反复遇到该错误。我已经尝试了互联网上的所有内容,但没有任何反应。我正在使用 Tomcat v10 和 JDK15.0.2。当我创建一个新的 JSP 文件时会发生此错误。
您需要 https://download.eclipse.org/releases/2021-03/ 的更新。对 Apache Tomcat 10 和 Jakarta EE JSP 的支持非常新。
我想你也可以使用 Tomcat 9.
Java EE ⇝ Jakarta EE
阅读 front page of downloading documentation for Apache Tomcat 10. 引用:
Users of Tomcat 10 onwards should be aware that, as a result of the move from Java EE to Jakarta EE as part of the transfer of Java EE to the Eclipse Foundation, the primary package for all implemented APIs has changed from javax.* to jakarta.*. This will almost certainly require code changes to enable applications to migrate from Tomcat 9 and earlier to Tomcat 10 and later.
并阅读 first page of the main documentation for Apache Tomcat 10. 引用:
Apache Tomcat version 10.0 implements the Servlet 5.0 and JavaServer Pages 3.0 specifications from Jakarta EE …
作为 Oracle 将所谓的 Java EE(企业版)的责任移交给 Eclipse 基金会的一部分,Jakarta EE are changing from javax.*
to jakarta.*
. You can read about this on the Tomcat page, Which version? — Apache Tomcat Versions, and on the internet.
- Tomcat 10 is for people moving forward to Jakarta EE versions 9 and later, using the
jakarta.*
namespace with the latest Servlet & JSP specs. - Tomcat 9 is for people sticking with the
javax.*
namespace using the popular Servlet 4 规范和相关 API。
如果您想使用最新的 API,请将 import
语句更改为使用 jakarta.
而不是 javax.
。或者将 Tomcat 10 换成 Tomcat 9 以使用旧的 javax.
命名空间。
- 如果您正在学习和试验,我建议使用
jakarta.
命名空间以及 Tomcat 10. - 如果您正在使用尚未更新到
jakarta.
命名空间的重要库或工具,请坚持使用旧 API 和 Tomcat 9.
有人讨论了通过自动化某些命名空间切换来提供帮助的工具。但是不知道那里的情况。