Java 如何在 localhost:8080/test/index.html 中打开我的资源?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20987714/
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
How to open my resource in that localhost:8080/test/index.html?
提问by Shans Muga
Tomcat started in eclipse and also I'm able to open the following URL in the browser:
Tomcat 在 Eclipse 中启动,我也可以在浏览器中打开以下 URL:
http://localhost:8080/test/index.html
But, I'm not able to open my resource in that page.
但是,我无法在该页面中打开我的资源。
Error that I am getting is:
我得到的错误是:
HTTP Status 404 - /
type Status report
message http:/test/index.html
description The requested resource (/test/index) is not available.
Apache Tomcat/6.0.29
回答by Bj?rn Steinemann
Please, try the following steps in eclipse to deploy the project as a WAR Fileand not as an EAR File:
请在 Eclipse 中尝试以下步骤,将项目部署为WAR 文件而不是EAR 文件:
- In the
Project Explorer
right click ontest
(which is the name of your project, if I got it right) - In the context menu choose
Export->WAR file
- In the dialog window that pops up click the
Browse...
button to choose the destination folder for the deployment. This should be the web application folder of yourTomcat
installation:<TOMCAT_INSTALLATION>/webapps
where<TOMCAT_INSTALLATION>
is the folder you have installed Tomcat in. - Click
Finish
- 在
Project Explorer
右键单击test
(这是您项目的名称,如果我没听错的话) - 在上下文菜单中选择
Export->WAR file
- 在弹出的对话窗口中单击
Browse...
按钮选择部署的目标文件夹。这应该是您Tomcat
安装的 Web 应用程序文件夹:您安装 Tomcat 的文件夹<TOMCAT_INSTALLATION>/webapps
在哪里<TOMCAT_INSTALLATION>
。 - 点击
Finish
Now start your Tomcat server. Assuming you have the index.html
file in the WebContent
folder of the test
project in Eclipse, you should see the content of index.html
in your browser when you open the URL.
现在启动您的 Tomcat 服务器。假设您在 Eclipse中的项目文件夹中有该index.html
文件,那么当您打开 URL 时,您应该会在浏览器中看到 的内容。WebContent
test
index.html