eclipse HTTP 状态 404 - 请求的资源 (/) 不可用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8520267/
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
HTTP Status 404 - The requested resource (/) is not available
提问by Vandan Patel
I integrated Tomcat 7 in Eclipse. When I start it using Eclipse, it shows that Tomcat is up and running, but when I go to http://localhost:8080in my browser, it gives me following error:
我在 Eclipse 中集成了 Tomcat 7。当我使用 Eclipse 启动它时,它显示 Tomcat 已启动并正在运行,但是当我在浏览器中访问http://localhost:8080时,它给了我以下错误:
HTTP Status 404 - /
typeStatus report
message/
descriptionThe requested resource (/) is not available.
Apache Tomcat/7.0.23
HTTP 状态 404 - /
类型状态报告
留言/
描述请求的资源 (/) 不可用。
Apache Tomcat/7.0.23
I tried changing the port in server.xml
just in case if 8080 is used by another service, but it didn't work either. How can I solve it?
我尝试更改端口,server.xml
以防万一 8080 被其他服务使用,但它也不起作用。我该如何解决?
回答by BalusC
What are you expecting? The default Tomcat homepage? If so, you'll need to configure Eclipse to take control over from Tomcat.
你在期待什么?默认的Tomcat主页?如果是这样,您需要配置 Eclipse 以从 Tomcat 接管控制。
Doubleclick the Tomcat server entry in the Serverstab, you'll get the server configuration. At the left column, under Server Locations, select Use Tomcat installation(note, when it is grayed out, readthe section leading text! ;) ). This way Eclipse will take full control over Tomcat, this way you'll also be able to access the default Tomcat homepage with the Tomcat Manager when running from inside Eclipse. I only don't see how that's useful while developing using Eclipse.
双击Servers选项卡中的 Tomcat 服务器条目,您将获得服务器配置。在左列的Server Locations 下,选择Use Tomcat installation(注意,当它变灰时,请阅读前导文本部分!;))。这样 Eclipse 将完全控制 Tomcat,这样您还可以在从 Eclipse 内部运行时使用 Tomcat 管理器访问默认的 Tomcat 主页。我只是不明白这在使用 Eclipse 进行开发时有什么用处。
The port number is not the problem. You would otherwise have gotten an exception in Tomcat's startup log and the browser would show a browser-specific "Connection timed out" error page (and thus not a Tomcat-specific error page which would impossibly be served when Tomcat was not up and running!)
端口号不是问题。否则,您将在 Tomcat 的启动日志中遇到异常,并且浏览器将显示特定于浏览器的“连接超时”错误页面(因此,当 Tomcat 未启动和运行时,不可能提供服务的特定于 Tomcat 的错误页面! )
回答by Amey Haldankar
Following steps helped me solve the issue.
以下步骤帮助我解决了这个问题。
- In the eclipse right click on server and click on properties.
- If Location is set workspace/metadata click on switch location and so that it refers to /servers/tomcatv7server at localhost.server
- Save and close
- Next double click on server
- Under server locations mostly it would be selected as use workspace metadata Instead, select use tomcat installation
- Save changes
- Restart server and verify localhost:8080 works.
- 在 Eclipse 中右键单击服务器并单击属性。
- 如果位置设置为工作空间/元数据,请单击切换位置并使其指向 localhost.server 处的 /servers/tomcatv7server
- 保存并关闭
- 接下来双击服务器
- 在大多数服务器位置下,它会被选择为使用工作区元数据,而是选择使用 tomcat 安装
- 保存更改
- 重新启动服务器并验证 localhost:8080 是否有效。
回答by Paul Thomas
Copy the ROOT (Default) Web App into Eclipse.
将 ROOT(默认)Web 应用程序复制到 Eclipse 中。
Eclipse forgets to copy the default apps (ROOT, examples, etc.) when it creates a Tomcat folder inside the Eclipse workspace.
Eclipse 在 Eclipse 工作区中创建 Tomcat 文件夹时忘记复制默认应用程序(ROOT、示例等)。
- Go to C:\apache-tomcat-7.0.27\webapps, R-click on the ROOT folder and copy it.
- Then go to your Eclipse workspace, go to the .metadata folder, and search for "wtpwebapps". You should find something like your-eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or .../tmp1/wtpwebapps if you already had another server registered in Eclipse).
- Go to the wtpwebapps folder, right-click, and paste ROOT (say "yes" if asked if you want to merge/replace folders/files).
- Then reload localhost:8080 to see the Tomcat welcome page.
- 转到 C:\apache-tomcat-7.0.27\webapps,右键单击 ROOT 文件夹并复制它。
- 然后转到 Eclipse 工作区,转到 .metadata 文件夹,然后搜索“wtpwebapps”。您应该找到类似 your-eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 的内容(如果您已经在 Eclipse 中注册了另一台服务器,则应找到.../tmp1/wtpwebapps)。
- 转到 wtpwebapps 文件夹,右键单击并粘贴 ROOT(如果询问您是否要合并/替换文件夹/文件,请说“是”)。
- 然后重新加载 localhost:8080 即可看到 Tomcat 欢迎页面。
回答by walox
I did what BalusC said but it was not enough for me, I had to clean the Tomcat workdirectory : ( Click right on right on Tomcat in the Servers Tab -> Clean Tomcat Work Directory )
我做了 BalusC 所说的,但对我来说还不够,我必须清理 Tomcat 工作目录 :(在服务器选项卡中的 Tomcat 上右键单击 -> 清理 Tomcat 工作目录)
回答by Advait
Please check in your server specification again, if you have changed your port number to something else. And change the port number in your link whatever new port number it is.
如果您已将端口号更改为其他内容,请再次检查您的服务器规范。并更改链接中的端口号,无论它是什么新端口号。
Also check whether your server is running properly before you try accessing your localhost.
在尝试访问本地主机之前,还要检查您的服务器是否运行正常。
回答by lukastymo
If you are new in JSP/Tomcat don't modify tomcat's xml files.
如果您是 JSP/Tomcat 新手,请不要修改 tomcat 的 xml 文件。
I assume you have already deployed web application. But to be sure, try these steps: - right click on your web application - select Run As / Run on Server, choose your Tomcat 7
我假设您已经部署了 Web 应用程序。但可以肯定的是,请尝试以下步骤: - 右键单击您的 Web 应用程序 - 选择 Run As / Run on Server,选择您的 Tomcat 7
These steps will deploy and run in the browser your application. Another idea to check if your Tomcat works correctly is to find path where tomcat exists (in eclipse plugin), and copy some working WAR file to webapps (not to wtpwebapps), and then try to run the app.
这些步骤将在浏览器中部署和运行您的应用程序。检查 Tomcat 是否正常工作的另一个想法是找到 tomcat 存在的路径(在 eclipse 插件中),并将一些工作 WAR 文件复制到 webapps(而不是 wtpwebapps),然后尝试运行该应用程序。
回答by Sourav Saha
Sometimes cleaning the server works. It worked for me many times.This is only applicable if the program worked earlier but suddenly it stops working.
Steps:
" Right click on Tomcat Server -> Clean. Then restart the server."
有时清理服务器是有效的。它对我有用很多次。这仅适用于程序较早运行但突然停止运行的情况。
步骤:
“ 右键单击Tomcat服务器->清理。然后重新启动服务器。”
回答by kansasian
If options under Server Locations are grayed out, note the message in the section title: "Server must be published with no modules present". To publish the server, right click the name of the server in the Server window and select "Publish".
如果服务器位置下的选项变灰,请注意部分标题中的消息:“服务器必须在不存在模块的情况下发布”。要发布服务器,请在服务器窗口中右键单击服务器名称并选择“发布”。
回答by Kevin S. Miller
For me, my Eclipse installation was hosed - I think because I'd installed struts. After trying a dozen remedies for this error, I re-installed Eclipse, made a new workspace and it was OK. Using Kepler-64-Windows, Tomcat 7, Windows 7.
对我来说,我的 Eclipse 安装失败了——我想是因为我安装了 struts。在为这个错误尝试了十几种补救措施后,我重新安装了 Eclipse,创建了一个新的工作区,一切正常。使用 Kepler-64-Windows、Tomcat 7、Windows 7。
回答by Gut Feeling
I had the same problem with my localhost project using Eclipse Luna, Maven and Tomcat - the Tomcat homepage would appear fine, however my project would get the 404 error.
我使用 Eclipse Luna、Maven 和 Tomcat 的 localhost 项目遇到了同样的问题 - Tomcat 主页看起来不错,但是我的项目会收到 404 错误。
After trying many suggested solutions (updating spring .jar file, changing properties of the Tomcat server, add/remove project, change JRE from 1.6 to 7 etc) which did not fix the issue, what worked for me was to just Refresh my project. It seems Eclipse does not automatically refresh the project after a (Maven) build. In Eclipse 3.3.1 there was a 'Refresh Automatically' option under Preferences > General > Workspace however that option doesn't look to be in Luna.
在尝试了许多没有解决问题的建议解决方案(更新 spring .jar 文件、更改 Tomcat 服务器的属性、添加/删除项目、将 JRE 从 1.6 更改为 7 等)后,对我有用的只是刷新我的项目。在(Maven)构建后,Eclipse 似乎不会自动刷新项目。在 Eclipse 3.3.1 中,“首选项”>“常规”>“工作区”下有一个“自动刷新”选项,但该选项似乎不在 Luna 中。
- Maven clean-install on the project.
- ** Right-click the project and select 'Refresh'. **
- Right-click the Eclipse Tomcat server and select 'Clean'.
- Right-click > Publish and then start the Tomcat server.
- 在项目上进行 Maven 全新安装。
- ** 右键单击项目并选择“刷新”。**
- 右键单击 Eclipse Tomcat 服务器并选择“清理”。
- 右键单击 > 发布,然后启动 Tomcat 服务器。