Tomcat 6.0之后如何替换ServletException?

发布于 2024-09-16 18:47:39 字数 711 浏览 4 评论 0原文

嘿,伙计们。 tomcat/apache新手,这里是java回归者。

我正在尝试运行分步示例 此处http://static .springsource.org/docs/Spring-MVC-step-by-step/part1.html)。

不幸的是,我不断收到一条错误消息“该项目未构建,因为其构建路径不完整。找不到 javax.servlet.http.HttpServletResponse 的类文件。修复构建路径,然后尝试构建项目。”我研究了一下,发现 javax.servlet 在 tomcat 的 conf/web.xml 文件中默认被注释掉,这是因为人们现在应该避免使用 servlet 之类的东西。

那么,我的问题是:

  1. 我如何重写它,使其符合导致它的原则?
  2. (奖励问题)一旦我在 tomcat 文件 conf/web.xml 中进行更改,如何才能使这些更改跟随到我的编辑器(在本例中为 Eclipse)中?

谢谢!

Hey, guys. Newbie to tomcat/apache, java returner here.

I'm trying to run th step-by-step example here (http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html).

Unfortunately, I keep getting an error that says "The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.http.HttpServletResponse. Fix the build path then try building the project." I looked into it and found out that javax.servlet is commented out by default in a conf/web.xml file for tomcat and that this was because people should now shun the use of servlets or something.

My questions, then, are:

  1. How do I rewrite this so that it's compliant with the principles that caused it?
  2. (Bonus Question) Once I make changes in that tomcat file, conf/web.xml, how do I make it so that those changes follow through into my editor (in this case, Eclipse)?

Thanks!

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

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

发布评论

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

评论(1

迷离° 2024-09-23 18:47:39

找不到 javax.servlet.http.HttpServletResponse 的类文件。修复构建路径,然后尝试构建项目。”

此编译错误意味着编译时类路径(构建路径)中缺少包含 Servlet API 的 JAR 文件。您需要包含 Tomcat 的 servlet-api.jar< /code> 位于构建路径中,按照 build.xml 文件中的注释。

我调查了一下,发现 javax.servlet 在 tomcat 的 conf/web.xml 文件中默认被注释掉,这是因为人们现在应该避免使用 servlet 或其他东西。

我不确定你在说什么,但事实上,当你开始 JSP/Servlet 开发时,你不应该碰 conf/web.xml 。默认的应该没问题。 Servlet API 当然不会被劝阻/弃用。它仍然是基于 Java 的 Web 应用程序最重要的核心构建基石。

也就是说,我也不清楚您的问题标题中的“如何在 Tomcat 6.0 之后替换 ServletException”的含义。您能否在您的问题中也详细说明这一点?

Cannot find the class file for javax.servlet.http.HttpServletResponse. Fix the build path then try building the project."

This compilation error means that the JAR file containing the Servlet API is missing in the compile time classpath (the build path). You need to include Tomcat's servlet-api.jar in the build path as per the comments in the build.xml file.

I looked into it and found out that javax.servlet is commented out by default in a conf/web.xml file for tomcat and that this was because people should now shun the use of servlets or something.

I am not sure what you're talking about, but you should in fact not touch the conf/web.xml when still starting with JSP/Servlet development. The default one should be fine. The Servlet API is certainly not discouraged/deprecated or so. It is still the most important core building stone of a Java based webapplication.

That said, it's unclear to me as well what you meant with "How to replace ServletException after Tomcat 6.0" in your question title. Can you elaborate on this in your question as well?

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