需要 javax.servlet.http.HttpServletRequest 的 JAR 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24356809/
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-08-14 11:45:21  来源:igfitidea点击:

Need the JAR file for a javax.servlet.http.HttpServletRequest

javaeclipseservletsjar

提问by Moon

I am modifying behavior of a web-app(server & client) running on web-sphere. I have de-compiled the code and just need to make minor changes and redeploy the code.

我正在修改在 web-sphere 上运行的 web 应用程序(服务器和客户端)的行为。我已经反编译了代码,只需要做一些小的更改并重新部署代码。

For this I made a simple Java Project with Eclipse EE and loaded all the de-compiled code. I only need the *.class files which I will convert to a JAR and place them at their proper place. The thing is there is a dependency which is not being resolved javax.servlet.http.HttpServletRequestso my project is not building

为此,我使用 Eclipse EE 创建了一个简单的 Java 项目并加载了所有反编译的代码。我只需要 *.class 文件,我会将其转换为 JAR 并将它们放在适当的位置。问题是有一个依赖项没有得到解决,javax.servlet.http.HttpServletRequest所以我的项目没有建立

How to resolve this dependency?

如何解决这种依赖?

If this dependency cannot be resolved than my guess is I could just get the JAR file for javax.servlet.http.HttpServletRequestand add to the Project's Build Path as an external JAR.

如果无法解决此依赖项,那么我的猜测是我可以获取 JAR 文件javax.servlet.http.HttpServletRequest并将其作为外部 JAR 添加到项目的构建路径中。

Where can I find the JAR for javax.servlet.http.HttpServletRequest

我在哪里可以找到 JAR javax.servlet.http.HttpServletRequest

p.s. I am new to JAVA so I don't know much about HttpServletRequestalso I am using Java 1.6 JRE.

ps 我是 JAVA 的新手,所以我对HttpServletRequest我使用的 Java 1.6 JRE 也不太了解。

回答by Matt

You'll want to add the Servlet API as a "provided" dependency. That is, you only use it to compile the code, but you don't need to package it with your web application since your web container will already contain a copy of it.

您需要将 Servlet API 添加为“提供的”依赖项。也就是说,您只使用它来编译代码,但您不需要将它与您的 Web 应用程序打包在一起,因为您的 Web 容器已经包含它的一个副本。

回答by James Drinkard

A long time ago I used to manually add the servletapi.jar into my eclipse project, but that is a bad practice.

很久以前,我曾经手动将 servletapi.jar 添加到我的 eclipse 项目中,但这是一种不好的做法。

Now I just create a Dynamic Web Project, then add a server (usually Tomcat), then right click on the new project - select properties - select project facets and add the Tomcat Server as the runtime. It has the files you need. Once you hit the apply button and okay button it will resolve the missing import files.

现在我只是创建一个动态Web项目,然后添加一个服务器(通常是Tomcat),然后右键单击新项目-选择属性-选择项目facets并添加Tomcat Server作为运行时。它有你需要的文件。点击应用按钮和确定按钮后,它将解决丢失的导入文件。

Here is a step by step description from a similar question on SO: How do I import the javax.servlet API in my Eclipse project?

以下是关于 SO 的类似问题的分步说明:如何在我的 Eclipse 项目中导入 javax.servlet API?

enter image description here

在此处输入图片说明

回答by Durgesh Gupta

Just Download Servlet.jar file from below link.

只需从下面的链接下载 Servlet.jar 文件。

http://www.java2s.com/Code/Jar/s/Downloadservletapi30jar.htm

http://www.java2s.com/Code/Jar/s/Downloadservletapi30jar.htm

add this jar file into your project using build path in eclipse.

使用 Eclipse 中的构建路径将此 jar 文件添加到您的项目中。