Eclipse 内部启动 Tomcat,浏览器访问出错的解决方法

在Eclipse里面配置好Tomcat服务器后,start server成功后,在浏览器输入http://localhost:8080/, 出现404错误,无法看到正常的tomcat页面。主要原因是eclipse里面的tomcat server配置问题,在server的 overview里面的server locations,选择下面的选项:

Use Tomcat installation (takes control of Tomcat installation)

参考资料如下:

If I start my Tomcat server and try to display Tomcat's default page, why do I see a directory listing or 404 error page?

When creating Tomcat servers in WTP, the default is for the Tomcat server to use a separate instance from the Tomcat installation for reasons explained in this question . There is no attempt to serve the standard Web applications found in the installation. Instead, a simple "ROOT" Web application, containing just a minimal web.xml file, is provided as the default context. The URL "http://localhost:8080/ " tries to display the welcome file at the base of this ROOT context. Since this ROOT context contains no welcome file, the default behavior for Tomcat is to display a directory listing. This is why you will see a directory listing for this URL with Tomcat 4.0, 4.1, and 5.0 servers. Directly listings have been disabled in Tomcat 5.5 and later, so the result is a 404 error page instead. To modify the Tomcat server in WTP to use the same server instance as the installation, see this question .

 

What configuration option determines whether the Tomcat server uses a separate instance or the instance from the Tomcat installation?

In WTP 1.5.x, the Run modules directly from the workspace (do not modify the Tomcat installation) check box of the server editor controls this option. It is found in the General section of the Overview page. If checked, a separate instance is used. If not checked, the instance from the Tomcat installation is used. The default is checked. It is best to change this option immediately after creating the server, or at least while no projects have been added to the server.

In WTP 2.0.x and later, the Server Locations section has been added to the server editor to provide improved control over this configuration issue. Choosing the Use workspace metadata (does not modify Tomcat installation) will use a separate instance and is equivalent to enabling WTP 1.5's Run modules directly... check box. In addition, the Server Path field displays the location of this separate instance relative to your workspace. A separate instance is also created if you choose Use custom location (does not modify Tomcat installation) and specify your desired location in the Server Path field. Choosing Use Tomcat installation (takes control of Tomcat installation) uses the instance from your Tomcat installation and is equivalent to disabling WTP 1.5's Run modules directly... check box.

Note that changes to the settings in the Server Locations section can only occur when there are no projects present on the server. All the settings in the section are disabled if this is not the case. Remove all of the projects and publish the server to enable the settings in this section.

你可能感兴趣的:(Eclipse 内部启动 Tomcat,浏览器访问出错的解决方法)