eclipse TOMCAT - HTTP 状态 404

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

TOMCAT - HTTP Status 404

eclipsetomcathttp-status-code-404

提问by GiGamma

I set up my server in eclipse and when I run it the console prints:

我在 eclipse 中设置了我的服务器,当我运行它时,控制台会打印:

mai 02, 2013 4:05:13 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files (x86)\Microsoft Application Virtualization Client;c:\Program Files (x86)\Open Text\View\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\ThinkPad\Bluetooth Software\;C:\Program Files\ThinkPad\Bluetooth Software\syswow64;;C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK.0\bin\x64;C:\Program Files\Java\jre7\bin;C:\WorkspacePPL\apache-maven-3.0.4\bin;.
mai 02, 2013 4:05:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ppl-webapp' did not find a matching property.
mai 02, 2013 4:05:13 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
mai 02, 2013 4:05:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 604 ms
mai 02, 2013 4:05:14 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
mai 02, 2013 4:05:14 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
mai 02, 2013 4:05:14 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
mai 02, 2013 4:05:14 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
mai 02, 2013 4:05:14 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/22  config=null
mai 02, 2013 4:05:14 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 493 ms

but then, if I browse http://localhost:8080I get:

但是,如果我浏览,http://localhost:8080我会得到:

HTTP Status 404 - /
---------------------------------------------------------------------
type Status report
message /
description The requested resource is not available.

While I should see the Tomcat welcome page.

虽然我应该看到 Tomcat 欢迎页面。

If I run Tomcat outside of eclipse I can reach the welcome page.

如果我在 Eclipse 之外运行 Tomcat,我可以访问欢迎页面。

回答by NINCOMPOOP

  1. Click on Window > Show view > Serveror right click on the server in "Servers" view, select "Properties".
  2. In the "General" panel, click on the "Switch Location" button.
  3. The "Location: [workspace metadata]" should replace by something else.
  4. Open the Overview screen for the server by double clicking it.
  5. In the Server locations tab , select "Use Tomcat location".
  6. Save the configurations and restart the Server.
  1. Window > Show view > Server在“服务器”视图中单击或右键单击服务器,选择“属性”。
  2. 在“常规”面板中,单击“切换位置”按钮。
  3. “位置:[工作区元数据]”应替换为其他内容。
  4. 通过双击打开服务器的概览屏幕。
  5. 在服务器位置选项卡中,选择“使用 Tomcat 位置”。
  6. 保存配置并重启服务器。

You may want to follow the steps above before starting the server. Because server location section goes grayed-unreachable.

您可能希望在启动服务器之前执行上述步骤。因为服务器位置部分变灰 - 无法访问。

server Locations in eclipse view

eclipse 视图中的服务器位置

回答by Agrata shukla

To get your program to run, please put jspfiles under web-content and not under WEB-INFbecause in Eclipse the files are not accessed there by the server, so try starting the server and browsing to URL:

为了让你的程序运行,请将jsp文件放在 web-content 下而不是放在 web-content 下,WEB-INF因为在 Eclipse 中,服务器不会访问这些文件,所以尝试启动服务器并浏览到 URL:

http://localhost:8080/YourProject/yourfile.jsp

then your problem will be solved.

那么你的问题就解决了。

回答by Peeter Kokk

You don't have to use Tomcat installation as a server location. It is much easier just to copy the files in the ROOT folder.

您不必使用 Tomcat 安装作为服务器位置。只需复制 ROOT 文件夹中的文件就容易多了。

Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace. Go to C:\apache-tomcat-7.0.8\webapps, R-click on the ROOT folder and copy it. Then go to your Eclipse workspace, go to the .metadatafolder, and search for "wtpwebapps". You should find something like your-eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps(or ../tmp1/wtpwebappsif you already had another server registered in Eclipse). Go to the wtpwebappsfolder, R-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files). Then reload http://localhost/to see the Tomcat welcome page.

Eclipse 在 Eclipse 工作区中创建 Tomcat 文件夹时忘记复制默认应用程序(ROOT、示例等)。转到 C:\apache-tomcat-7.0.8\webapps,右键单击 ROOT 文件夹并复制它。然后转到您的 Eclipse 工作区,转到该.metadata文件夹,然后搜索“wtpwebapps”。您应该找到类似的东西 your-eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps(或者../tmp1/wtpwebapps如果您已经在 Eclipse 中注册了另一台服务器)。转到wtpwebapps文件夹,右击并粘贴 ROOT(如果询问您是否要合并/替换文件夹/文件,请说“是”)。然后重新加载http://localhost/即可看到Tomcat欢迎页面。

Source: HTTP Status 404 error in tomcat

来源:tomcat 中的 HTTP 状态 404 错误