Tomcat 6.0之后如何替换ServletException?
嘿,伙计们。 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 之类的东西。
那么,我的问题是:
- 我如何重写它,使其符合导致它的原则?
- (奖励问题)一旦我在 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:
- How do I rewrite this so that it's compliant with the principles that caused it?
- (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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此编译错误意味着编译时类路径(构建路径)中缺少包含 Servlet API 的 JAR 文件。您需要包含 Tomcat 的
servlet-api.jar< /code> 位于构建路径中,按照
build.xml
文件中的注释。我不确定你在说什么,但事实上,当你开始 JSP/Servlet 开发时,你不应该碰
conf/web.xml
。默认的应该没问题。 Servlet API 当然不会被劝阻/弃用。它仍然是基于 Java 的 Web 应用程序最重要的核心构建基石。也就是说,我也不清楚您的问题标题中的“如何在 Tomcat 6.0 之后替换 ServletException”的含义。您能否在您的问题中也详细说明这一点?
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 thebuild.xml
file.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?