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首页都不行,加上项目名也是一样的。
11 个月之前 回复
candy_rainbow
candy_rainbow   2017.01.14 23:56

使用127.0.0.1试一试

tanpf123
tanpf123 试过了,也是访问不了
11 个月之前 回复
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
11 个月之前 回复
qq_36423978
qq_36423978   2017.01.15 14:15

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

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

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

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

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

nihao0502
nihao0502   2017.01.16 21:01

eclipse配置不正确

tanpf123
tanpf123 ????
11 个月之前 回复
共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!