Java Apache Tomcat 404 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1163493/
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
Apache Tomcat 404 Error
提问by hello_world_infinity
I downloaded Apache Tomcat 6.0.2 And created a new server in Eclipse
我下载了 Apache Tomcat 6.0.2 并在 Eclipse 中创建了一个新服务器
- New -> Server
- Select "Tomcat v6.0 Server", Next
- Tomcat Installation Directory -> Where I unzipped Apache Tomcat 6.0.2
- Finish
- 新建 -> 服务器
- 选择“Tomcat v6.0 Server”,下一步
- Tomcat 安装目录 -> 我解压 Apache Tomcat 6.0.2 的位置
- 结束
Then I start the server and go to http://localhost:8080/to see if it works. And I get a 404 error.
然后我启动服务器并转到http://localhost:8080/以查看它是否有效。我收到 404 错误。
I've already googled it and tried to find a solution. But none of those remedies seem to work.
我已经用谷歌搜索了它并试图找到解决方案。但这些补救措施似乎都不起作用。
Any thoughts on what the problem is?
关于问题是什么的任何想法?
回答by drvdijk
From the top of my head, I thought Eclipse started the tomcat server without anything in it, i.e. no web applications. You have to 'run' or actually deploy something in that Eclipse Tomcat server so you won't get the 404s.
在我的脑海中,我认为 Eclipse 启动了没有任何内容的 tomcat 服务器,即没有 Web 应用程序。您必须在该 Eclipse Tomcat 服务器中“运行”或实际部署某些内容,这样您就不会得到 404。
The fact that you do get 404 error messages indicates that Tomcat actually IS running. If you shut it down from Eclipse, you won't get those 404's anymore ;)
您确实收到 404 错误消息这一事实表明 Tomcat 实际正在运行。如果你从 Eclipse 中关闭它,你就不会再得到那些 404 了 ;)
回答by sourcerebels
I agree to drvdijk.
我同意 drvdijk。
Go to "Servers" window, then select your Tomcat instance. Double.click here you will see the "overview" window. Here you can click on "Open launch configuration" to see your Tomcat arguments ("Arguments" tab).
转到“服务器”窗口,然后选择您的 Tomcat 实例。双击此处您将看到“概览”窗口。在这里,您可以单击“打开启动配置”以查看您的 Tomcat 参数(“参数”选项卡)。
Look for the system property "-Dwtp.deploy". This directory is where your Tomcat is looking for installed web applications, i think you don't have ROOT.war application here. Isn't it? :-)
查找系统属性“-Dwtp.deploy”。这个目录是你的 Tomcat 正在寻找安装的 web 应用程序的地方,我想你这里没有 ROOT.war 应用程序。不是吗?:-)
Hope this will help you
希望能帮到你
回答by Titi Wangsa bin Damhore
i think the problem is http://localhost:8080/when you should use http://localhost:8080/appname
我认为问题是http://localhost:8080/当你应该使用 http://localhost:8080/appname
回答by kumikoda
The problem is just as drvdijk mentioned, in order to run a webapp on tomcat from eclipse, it needs to be "deployed" to it. This can be done by right clicking the tomcat server -> add and remove
问题正如 drvdijk 提到的,为了从 eclipse 在 tomcat 上运行 webapp,它需要“部署”到它。这可以通过右键单击 tomcat 服务器 -> 添加和删除来完成
Alternatively, you can try to startup your tomcat server outside of eclipse. Go to your command line and type
或者,您可以尝试在 eclipse 之外启动您的 tomcat 服务器。转到您的命令行并键入
$CATALINA_HOME\bin\startup.bat (Windows)
$CATALINA_HOME/bin/startup.sh (Unix)
Where $catalina_home is the directory of where you installed tomcat
$catalina_home 是你安装tomcat的目录
回答by JavaCoder
see if below URL Helps to resolve the issue
看看下面的网址是否有助于解决问题
回答by El Wexicano
If your wanting to see your Tomcat Server Homepage then you will need to specify the server path and deploy path. The default is set to Use workspace metadata (does not modify your Tomcat installation).
如果您想查看 Tomcat 服务器主页,则需要指定服务器路径和部署路径。默认设置为使用工作区元数据(不修改您的 Tomcat 安装)。
How to do it.
怎么做。
- Firstly open the Server's view in Eclipse. (Window >> Show View >> Servers).
- Double click on your Tomcat Server to open the Server Overview.
- Then set the Server Locations to Use Tomcat installation (takes control of Tomcat installation). Save the changes.
- Restart your Server and then go to localhost:8080. This should open the Apache Tomcat Homepage for your server.
- 首先在Eclipse中打开Server的视图。(窗口>>显示视图>>服务器)。
- 双击您的 Tomcat 服务器以打开服务器概览。
- 然后将服务器位置设置为使用 Tomcat 安装(控制 Tomcat 安装)。保存更改。
- 重新启动您的服务器,然后转到localhost:8080。这应该会为您的服务器打开 Apache Tomcat 主页。
Hope this helps!
希望这可以帮助!
回答by Sonu
The error 404 appears when Tomcat can't find the localhost.ser file. In order to get rid of this follow these steps: 1) In Eclipse, right click on server --> Properties --> Click Switch Location --> Apply-->Ok (This will switch the [workspace metadata] location to the installed Tomcat location.) 2) Then go back to server, double click it. This will open Overview tab. Under this tab goto -->Server Location --> Select Use Tomcat Installation combo box.
Tomcat 找不到 localhost.ser 文件时会出现 404 错误。为了摆脱这种情况,请执行以下步骤: 1) 在 Eclipse 中,右键单击服务器 --> 属性 --> 单击切换位置 --> 应用 --> 确定(这会将 [工作区元数据] 位置切换到安装Tomcat的位置。) 2)然后回到服务器,双击它。这将打开概览选项卡。在此选项卡下转到 --> 服务器位置 --> 选择使用 Tomcat 安装组合框。
Now close it, save it and try run your server and then rerun the URL.
现在关闭它,保存它并尝试运行您的服务器,然后重新运行 URL。
回答by Ashish Anand
Launch your eclipse Run as administration:
For that right click on eclipse-----> run as administration.
It works.
启动您的 eclipse以管理员身份运行:
为此,右键单击 eclipse-----> 以管理员身份运行。
有用。
If it not works then again do same and then follow these steps:
如果它不起作用,则再次执行相同的操作,然后按照以下步骤操作:
In Eclipse, right click on server --> Properties --> Click Switch Location --> Apply-->Ok
(This will switch the [workspace metadata] location to the installed Tomcat location.)Then go back to server, double click it. This will open Overview tab. Under this tab goto -->Server Location --> Select Use Tomcat Installationcombo box.
在 Eclipse 中,右键单击服务器 --> 属性 --> 单击切换位置 --> 应用 --> 确定
(这会将 [工作区元数据] 位置切换到已安装的 Tomcat 位置。)然后回到服务器,双击它。这将打开概览选项卡。在此选项卡下转到 --> 服务器位置 --> 选择使用 Tomcat 安装组合框。
Now close it, save it and try run your server and then rerun the URL.
现在关闭它,保存它并尝试运行您的服务器,然后重新运行 URL。
回答by shareef
回答by Davide Castronovo
Also, notice if you have a duplicated WEB-INF in your path. Sometimes after update a maven project you may have this issue and Tomcat points to an empty folder.
另外,请注意您的路径中是否有重复的 WEB-INF。有时在更新 Maven 项目后,您可能会遇到此问题,并且 Tomcat 指向一个空文件夹。