2 tanpf123 tanpf123 于 2017.01.14 22:40 提问

eclipse中tomcat启动成功,访问不了tomcat首页 ? 2C

我在eclipse中的tomcat成功启动了,环境变量配置好了的,端口也没被占用,但是localhost:8080却找不到服务器,127.0.0.1:8080也是一样。(外部启动tomcat是可以访问的) 但最近发现把公用网络的防火墙关闭后,就可以访问了!这是为什么呢?

其中server的设置为:

图片说明

控制台:

图片说明

tomcat的webapp中的root为:

图片说明

最终网页显示:

图片说明

外部启动访问成功:

图片说明

server.xml:

 <?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 --><Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the BIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine defaultHost="localhost" name="Catalina">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>

      <Context docBase="JavaMail" path="/JavaMail" reloadable="true" source="org.eclipse.jst.jee.server:JavaMail"/></Host>
    </Engine>
  </Service>
</Server>

11个回答

JE_GE
JE_GE   2017.01.14 23:10

你把外部运行的tomcat dos截屏看看,有点怪哦

u010528826
u010528826   2017.01.14 23:36

确实很奇怪。看不出来问题在哪。。。。

u011095110
u011095110   2017.01.14 23:41

看不见你localhost后面的项目名。加上项目名试试?

tanpf123
tanpf123 单独访问tomcat首页都不行,加上项目名也是一样的。
一年多之前 回复
candy_rainbow
candy_rainbow   2017.01.14 23:56

使用127.0.0.1试一试

tanpf123
tanpf123 试过了,也是访问不了
一年多之前 回复
tianshi1017
tianshi1017   2017.01.15 09:42

Servcer locations 配置中的 deploy path 变为:wtpwebapps

maqiang0422
maqiang0422   2017.01.15 12:09

Server locations 配置中是自己配的吧?
我的配置是 Use worksapce metadata

Server path : .metadata.plugins\org.eclipse.wst.sse.core

Deploy path: wtpwebapps
你看看是不是这里配置错误。一般都是eclipse里默认配置的,根据你的Tomcat和工作空间。

tanpf123
tanpf123 之前我的配置跟你的也是一样的,可是也是访问不了,最后换成了Server path : .metadata.plugins\org.eclipse.wst.sse.core Deploy path: webapps
一年多之前 回复
qq_36423978
qq_36423978   2017.01.15 14:15

你看看tomact是否启动,还有你项目是否配置tomact。。。

tanpf123
tanpf123 已经启动了,现在还没创建项目,只是想测试一下在eclipse中启动tomcat能不能访问首页而已
一年多之前 回复
struggleflea
struggleflea   2017.01.16 11:29

127.0.0.1可以,localhost不行,是不是以前设置过代理什么的,配置下host看看。

tanpf123
tanpf123 这个host怎么配置??
一年多之前 回复
qq_17311469
qq_17311469   2017.01.16 15:11

把tomcat里面的 server.xml截图出来看看,看你配置的端口,在看你配置的项目

nihao0502
nihao0502   2017.01.16 21:01

eclipse配置不正确

tanpf123
tanpf123 ????
一年多之前 回复
共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
解决Tomcat不能访问首页的问题,eclipse中tomcat能正常启动
在eclipse中Tomcat能够正常启动,并能访问JSP文件,但是浏览器问题localhost:8080访问不了首页。 解决方法如下:1.首先关闭eclipse,然后再再地址栏中输入localhost:8080 这一步是检查是否正确安装了Tomcat。 若能正常访问则说明安装正确; 若不能只重新安装Tomcat。2.打开Eclipse把tomcat下的所有项目删除。然后右击,选择clean
利用Eclipse启动Tomcat后,访问不了欢迎页
在eclipse中双击servers中的tomcat打开(只有启动tomacat之后双击才能打开) 在overview修改server locations 的三个单选 选 use tomcat installation(takes control of tomcat installation) deploy path 填 webapps 如下图:
eclipse启动tomcat成功,可以访问tomcat主页,但项目访问不了
问题:tomcat主页可以访问,但是项目访问不了 原因:没有index.jsp文件或者没有将index.jsp文件放到WebContent的目录下。 如果是放在WEB-INF目录中,又没有进行配置,页面也是不能被访问的。
eclipse中tomcat能正常启动,但是浏览器访问不了tomcat首页之tomcat配置问题
eclipse tomcat 配置问题
eclipse启动tomcat却访问不了tomcat主页问题
eclipse安装了自己下载的tomcat,之前直接在服务器上运行工程都没出现问题,
eclipse中tomcat能正常启动,但是浏览器访问不了tomcat首页
在eclipse中新建tomcat7,完成后tomcat能够正常启动,但是浏览器问题localhost:8080访问不了。 解决方法如下: 双击eclipse中服务器中的tomcat 出现tomcat的配置界面 然后Server Locations中选择如图,将Deploy path选择到tomcat目录中的webapps目录,然后保存,重启tomcat后,
解决eclipse中启动Tomcat成功但是访问不了Tomcat问题
自己搭建了一个springMVC项目,中间出了一些问题,在排查问题的过程中发现eclipse成功启动了Tomcat,但是在浏览器中输入localhost:8080却给我一个冷冷的404,我以为是Tomcat出问题了(心情大好,以为自己搭建的项目没有问题),然后跑去Tomcat的bin目录中运行start.bat发现启动正常(心里有点凉),然后在浏览器中输入localhost:8080,讨厌的猫竟然
Eclipse正常启动tomcat但无法访问主页
症状: tomcat在eclipse里面能正常启动,而在浏览器中访问http://localhost:8080/不能访问,且报404错误。同时其他项目页面也不能访问。 关闭eclipse里面的tomcat,在tomcat安装目录下双击startup.bat手动启动tomcat服务器。访问htt://localhost:8080/能正常访问tomcat管理页面。 症状原因:
在tomcat目录下启动tomcat,可以正常访问tomcat主页,然在在eclipse中集成了tomcat却访问不了tomcat主页,却能访问发布的项目
tomcat server在eclipse中正常配置了,在eclipse建tomcat服务是在server 视图那里new server建立的,但把项目部署到tomcat后却发现tomcat主页报404的错误,然后在tomcat的webapps查看却没发现我部署的项目,但是既然没有部署到自己的tomcat为什么又能正常访问项目呢?原来使用new server这种方式默认是使用eclipse自带的ec
在Eclipse中启动tomcat后访问tomcat首页时出现404
在Eclipse中配置好tomcat后,把一个web项目发布到tomcat上去,当使用http://localhost:8080访问tomcat首页时出现404错误,但可以正常访问web页面,然而当在tomcat文件中单独启动tomcat时却可以正常访问tomcat首页,如图所示 对于这个问题,是Eclipse中默认设置出了问题,解决方案如下: 1.找到server操作窗口,双击下面的