eclipse 运行 Web 应用程序时出现错误“HTTP 状态 404”-“请求的资源不可用”?

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

Getting error "HTTP Status 404" -" The requested resource is not available" when running a web application?

javaeclipsetomcatweb-applications

提问by Vikash Chahal

I am using the eclipse helios and tomcat 7.0.33 to develope the web application . I am making use of "com.sysdeo.eclipse.tomcat_3.3.0" plugin with the eclise helios and have added the server(tomcat) using preferences to the eclipse.

我正在使用 eclipse helios 和 tomcat 7.0.33 来开发 web 应用程序。我正在使用带有 eclise helios 的“com.sysdeo.eclipse.tomcat_3.3.0”插件,并使用偏好将服务器(tomcat)添加到 eclipse 中。

Also I am successfully able to start and stop the tomcat server . I am using pre-installed jre as Java with the server.

此外,我能够成功启动和停止 tomcat 服务器。我在服务器上使用预装的 jre 作为 Java。

But I am not able to successfully run the web applcation. I am also downloaded the zip example from the internet and imported in the eclipse , but was not able to successfully run it.

但我无法成功运行 Web 应用程序。我还从互联网上下载了 zip 示例并导入到 eclipse 中,但无法成功运行它。

Is there any good links explaining how to use the Eclipse Helios and Tomcat 7.0.33 to develop the dynamic web applications and successfully run them???

是否有任何好的链接解释如何使用 Eclipse Helios 和 Tomcat 7.0.33 来开发动态 Web 应用程序并成功运行它们???

Or what other could be the reason of this error????

或者还有什么其他可能是这个错误的原因????

Looking for Help!!!!!

寻求帮助!!!!

回答by Brian Harris

Hmm, did you add the project to the Tomcat instance? Under the server view, if you expand(+) the listed Tomcat server is the project displayed underneath? If not, right click on the server and use the add/remove dialog.

嗯,你把项目添加到Tomcat实例了吗?在服务器视图下,如果展开(+) 列出的Tomcat 服务器是下面显示的项目吗?如果没有,请右键单击服务器并使用添加/删除对话框。

If you've done all that, and the project is indeed added to Tomcat, are there any errors that appear when you try to run one of the JSPs? For example, if you selected your welcome page, right clicked and selected Run As --> Run on Server, do you see any errors?

如果您已经完成了所有这些工作,并且该项目确实已添加到 Tomcat,那么在您尝试运行其中一个 JSP 时是否会出现任何错误?例如,如果您选择了欢迎页面,右键单击并选择运行方式 --> 在服务器上运行,您是否看到任何错误?

EDIT: my apologies, I see you are stating you are seeing a 404 exception. Perhaps try to remove and re-add the project using the add/remove dialog. I know I've seen it get wonky sometimes and that may reset any configuration errors.

编辑:抱歉,我看到您说您看到的是 404 异常。也许尝试使用添加/删除对话框删除并重新添加项目。我知道我看到它有时会变得不稳定,这可能会重置任何配置错误。

Here are some more details - hope they help:

以下是更多详细信息 - 希望它们有所帮助:

So, Here is my empty Tomcat server (running) in my IDE. here is my empty tomcat in Eclipse

所以,这是我的 IDE 中的空 Tomcat 服务器(正在运行)。 这是我在 Eclipse 中的空 tomcat

To add my project, I right-click to view the context menu shown, and select Add and Remove. add and remove project to Tomcat in Eclipse IDE

要添加我的项目,我右键单击以查看显示的上下文菜单,然后选择添加和删除。 在 Eclipse IDE 中向 Tomcat 添加和删除项目

When I select Add and Remove, I see this dialog showing the projects that can be added. I select the project(s) to add, hit the add button and then finish. Add and Remove empty

当我选择添加和删除时,我会看到此对话框显示可以添加的项目。我选择要添加的项目,点击添加按钮,然后完成。 添加和删​​除空

Once that is done, I see that my project(s) have been added to my tomcat instance. enter image description here

完成后,我看到我的项目已添加到我的 tomcat 实例中。 在此处输入图片说明

Again, Tomcat may need a restart.

同样,Tomcat 可能需要重新启动。

回答by Vikash Chahal

oki.. Now I am adding the server from the starting again . I have removed all the previous things and the plugins .

oki.. 现在我从头开始添加服务器。我已经删除了所有以前的东西和插件。

Again starting from the

再次从

server tab-> Right Click on Server Tab( in the Bottom) -> New

服务器选项卡-> 右键单击​​服务器选项卡(在底部)-> 新建

->Server and then Selected "Tomcat v7.0 Server" .

->Server 然后选择“Tomcat v7.0 Server”。

In the new server Environment, I am using the following details

在新的服务器环境中,我使用了以下细节

 Name :- Apache Tomcat v7.0 (3)

Tomcat Installation Directory :-C:\Documents and Settings9451\My Documents\Tomcat_7\apache-tomcat-7.0.33,,,   JRE :- jre6(installed JRE) 

and then I clicked on Finish Button.

然后我点击了完成按钮。

Then on the Define a New Server Dialog I am using the details

然后在“定义新服务器”对话框中,我使用了详细信息

Server's Host Name :- localhost

服务器的主机名:- 本地主机

Server Name :- Tomcat v7.0 Server at localhost

服务器名称:- 本地主机上的 Tomcat v7.0 服务器

Server runtime Environment :- Apache Tomcat v7.0

服务器运行环境:- Apache Tomcat v7.0

Then I clicked on the finish button and the added tomcat server is now shown in the window under Server Tab.

然后我点击完成按钮,添加的 tomcat 服务器现在显示在服务器选项卡下的窗口中。

But when I typed the URL : "http://localhost:8080/"

但是当我输入 URL 时:“http://localhost:8080/”

Then I am getting the following error :

然后我收到以下错误:

HTTP Status 404 -/

HTTP 状态 404 -/

type :- Status report

类型:- 状态报告

message :-/

信息 :-/

description :-The requested resource is not available.

描述:-请求的资源不可用。

What could be the reason of this error?

这个错误的原因可能是什么?

Looking for Help!

寻求帮助!

回答by Vikash

This is an old question, but maybe I could help someone who lands here.

这是一个老问题,但也许我可以帮助到这里的人。

In case you are unable to get your tomcat up and running, you should double click on the created server in the servers tab in eclipse. A new tab would open inside eclipse. There, under Server locations, select the middle option, "Use Tomcat Installation". Then hit https://localhost:8080/. It should work

如果您无法启动并运行您的 tomcat,您应该在 eclipse 的服务器选项卡中双击创建的服务器。一个新选项卡将在 eclipse 中打开。在那里,在服务器位置下,选择中间选项“使用 Tomcat 安装”。然后点击https://localhost:8080/。它应该工作

Please note that if you already have added a war file, you should remove it before you try the above suggestion.

请注意,如果您已经添加了一个War文件,您应该在尝试上述建议之前将其删除。

Hope it helps.

希望能帮助到你。