404错误,Tomcat首页都打不开

404错误,Tomcat首页都打不开

http://img1.sycdn.imooc.com//climg/5db9558909f5013c19281048.jpg

D:\apache-tomcat-8.5.43\bin\catalina.bat run
[2019-10-30 05:00:41,618] Artifact icake:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3"
Using CATALINA_HOME:   "D:\apache-tomcat-8.5.43"
Using CATALINA_TMPDIR: "D:\apache-tomcat-8.5.43\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_201"
Using CLASSPATH:       "D:\apache-tomcat-8.5.43\bin\bootstrap.jar;D:\apache-tomcat-8.5.43\bin\tomcat-juli.jar"
Connected to the target VM, address: '127.0.0.1:33648', transport: 'socket'
30-Oct-2019 17:00:44.715 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.43
30-Oct-2019 17:00:44.718 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jul 4 2019 20:53:15 UTC
30-Oct-2019 17:00:44.718 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.43.0
30-Oct-2019 17:00:44.718 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
30-Oct-2019 17:00:44.719 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
30-Oct-2019 17:00:44.719 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
30-Oct-2019 17:00:44.719 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_201\jre
30-Oct-2019 17:00:44.720 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_201-b09
30-Oct-2019 17:00:44.720 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
30-Oct-2019 17:00:44.720 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3
30-Oct-2019 17:00:44.720 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         D:\apache-tomcat-8.5.43
30-Oct-2019 17:00:44.721 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3\conf\logging.properties
30-Oct-2019 17:00:44.721 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
30-Oct-2019 17:00:44.721 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:33648,suspend=y,server=n
30-Oct-2019 17:00:44.721 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -javaagent:C:\Users\WZW\.IntelliJIdea2019.1\system\captureAgent\debugger-agent.jar
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3\jmxremote.password
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3\jmxremote.access
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
30-Oct-2019 17:00:44.723 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
30-Oct-2019 17:00:44.724 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
30-Oct-2019 17:00:44.726 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\WZW\.IntelliJIdea2019.1\system\tomcat\Unnamed_icake_3
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=D:\apache-tomcat-8.5.43
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=D:\apache-tomcat-8.5.43\temp
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
30-Oct-2019 17:00:44.727 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
30-Oct-2019 17:00:44.735 淇℃伅 [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1c  28 May 2019]
30-Oct-2019 17:00:45.116 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
30-Oct-2019 17:00:45.146 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Oct-2019 17:00:45.176 淇℃伅 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
30-Oct-2019 17:00:45.184 淇℃伅 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
30-Oct-2019 17:00:45.185 淇℃伅 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1186 ms
30-Oct-2019 17:00:45.255 淇℃伅 [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
30-Oct-2019 17:00:45.256 淇℃伅 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.43
30-Oct-2019 17:00:45.272 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
30-Oct-2019 17:00:45.291 淇℃伅 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
30-Oct-2019 17:00:45.302 淇℃伅 [main] org.apache.catalina.startup.Catalina.start Server startup in 117 ms
Connected to server
[2019-10-30 05:00:45,436] Artifact icake:war exploded: Artifact is being deployed, please wait...
30-Oct-2019 17:00:47.690 淇℃伅 [RMI TCP Connection(2)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2019-10-30 05:00:47,849] Artifact icake:war exploded: Artifact is deployed successfully
[2019-10-30 05:00:47,849] Artifact icake:war exploded: Deploy took 2,414 milliseconds
30-Oct-2019 17:00:55.288 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [D:\apache-tomcat-8.5.43\webapps\manager]
30-Oct-2019 17:00:55.437 淇℃伅 [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
30-Oct-2019 17:00:55.456 淇℃伅 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [D:\apache-tomcat-8.5.43\webapps\manager] has finished in [167] ms


正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

5回答
芝芝兰兰 2019-10-31 10:57:08

同学你好。既然产生了楼下的404页面。Tomcat本身是没有问题的。

注意出现404页面和出现白屏的情况不同。一般来说,白屏的情况有几种可能:

1)项目没有成功发布到Tomcat中 

2)Servlet运行时控制台console报错 

3)Servlet跳转失败 

4)页面留在了Servlet没有跳转等等。

综上同学的需要先看一下请求对应的流程上是否有卡住的

1、可以对比检查一下GlobalController是否有拼写错误,这里的路径是否不匹配 :http://img1.sycdn.imooc.com//climg/5dba4caa09ca372917180627.jpg

package com.imooc.icake.global;

import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

public class GlobalController extends GenericServlet {


    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        /*
        .do
        /login.do           DefaultController   login
        /Cake/detail.do     CakeController      detail
        /admin/Cake/add.do  CakeController      add
         */
        HttpServletRequest request = (HttpServletRequest) servletRequest;
        HttpServletResponse response = (HttpServletResponse)servletResponse;
        String path = request.getServletPath();
        if(path.indexOf("/admin")!=-1){
            path = path.substring(7);
        }else{
            path = path.substring(1);
        }
        /*
        login.do           DefaultController   login
        Cake/detail.do     CakeController      detail
        Cake/add.do  CakeController      add
         */
        int index = path.indexOf("/");
        String className =null;
        String methodName =null;
        if(index!=-1){
            className = "com.imooc.icake.controller."+path.substring(0,index)+"Controller";
            methodName = path.substring(index+1,path.indexOf(".do"));
        }else{
            className = "com.imooc.icake.controller.DefaultController";
            methodName = path.substring(0,path.indexOf(".do"));
        }
        try {
            Class cla = Class.forName(className);
            Object object = cla.newInstance();
            Method method = cla.getMethod(methodName,HttpServletRequest.class, HttpServletResponse.class);
            method.invoke(object,request,response);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

2、检查下对应的方法是否已经实现,转发是否写错,是否漏写了forword:

http://img1.sycdn.imooc.com//climg/5dba4d0d090a302113810284.jpg

3、页面对应的路径是否能找到:

http://img1.sycdn.imooc.com//climg/5dba4d6209453a5618310595.jpg

祝学习愉快~

提问者 慕瓜皮 2019-10-30 19:38:02
提问者 慕瓜皮 2019-10-30 19:36:26
提问者 慕瓜皮 2019-10-30 18:19:29
  • 同学访问的地址是什么呢?浏览器中的404页面的截图也需要提供下~祝学习愉快~
    2019-10-30 18:24:47
  • 同学你好。访问下“localhost:8080/icake_war_exploded/admin/Catelog/list.do”试一下呢?访问下“localhost:8080/icake_war_exploded/toLogin.do”试一下呢?
    2019-10-30 19:12:30
  • 提问者 慕瓜皮 回复 芝芝兰兰 #3
    现在连Tomcat的首页都是404错误,请问这是什么原因啊
    2019-10-30 19:39:52
芝芝兰兰 2019-10-30 18:13:11

同学你好。看同学控制台输出的信息中并没有报错呢,只是日志。看同学的项目上下文路径为“/icake_war_exploded”同学是否是使用“localhost:8080/icake_war_exploded”访问的呢?

http://img1.sycdn.imooc.com//climg/5db95ac809adc27308260522.jpg

如果没有解决,可以将访问地址及404页面截一下图。另外提供下这个页面的截图

http://img1.sycdn.imooc.com//climg/5db9618f0974ec7e11480694.jpg

祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师