tomcat 404 java spring mvc

web.xml

    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

mvc-dispatcher-servlet.xml

    <context:component-scan base-package="com.XXX.controller"/>

    <!-- 静态资源(js、image等)的访问 -->
    <mvc:default-servlet-handler/>

    <!-- 开启注解 -->
    <mvc:annotation-driven/>

    <!--ViewResolver 视图解析器-->
    <!--用于支持Servlet、JSP视图解析-->
    <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

我觉得代码和配置都应该没问题,启动时候就是tomcat 404

按照相关问题 的解决方案对应的/改成/*也没有用。

觉得可能是 tomcat 的问题

以下是启动时的日志:

"C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\catalina.bat" run
[2018-04-13 11:00:50,753] Artifact springmvcdemo5:war exploded: Waiting for server connection to start artifact deployment...
Using CATALINA_BASE:   "C:\Users\inren\.IntelliJIdea2018.1\system\tomcat\Unnamed_springmvcdemo5_2"
Using CATALINA_HOME:   "C:\Program Files\Apache Software Foundation\Tomcat 8.0"
Using CATALINA_TMPDIR: "C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp"
Using JRE_HOME:        "C:\Program Files\Java\jdk1.8.0_144"
Using CLASSPATH:       "C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\bootstrap.jar;C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\tomcat-juli.jar"
13-Apr-2018 11:00:51.747 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.0.45
13-Apr-2018 11:00:51.750 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Jun 26 2017 20:06:07 UTC
13-Apr-2018 11:00:51.750 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.0.45.0
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk1.8.0_144\jre
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_144-b01
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\inren\.IntelliJIdea2018.1\system\tomcat\Unnamed_springmvcdemo5_2
13-Apr-2018 11:00:51.751 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 8.0
13-Apr-2018 11:00:51.752 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\inren\.IntelliJIdea2018.1\system\tomcat\Unnamed_springmvcdemo5_2\conf\logging.properties
13-Apr-2018 11:00:51.752 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
13-Apr-2018 11:00:51.752 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
13-Apr-2018 11:00:51.752 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
13-Apr-2018 11:00:51.752 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 8.0\endorsed
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\inren\.IntelliJIdea2018.1\system\tomcat\Unnamed_springmvcdemo5_2
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 8.0
13-Apr-2018 11:00:51.753 信息 [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 8.0\temp
13-Apr-2018 11:00:51.754 信息 [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_144\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;D:\oracle\product\11.2.0\client_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\TortoiseSVN\bin;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Git\cmd;C:\Program Files (x86)\VisualSVN\bin;C:\Program Files\nodejs\;";D:\Tools\apache-maven-3.5.3\bin";"C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;";;.
13-Apr-2018 11:00:51.921 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
13-Apr-2018 11:00:51.947 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
13-Apr-2018 11:00:51.949 信息 [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
13-Apr-2018 11:00:51.952 信息 [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
13-Apr-2018 11:00:51.953 信息 [main] org.apache.catalina.startup.Catalina.load Initialization processed in 606 ms
13-Apr-2018 11:00:51.993 信息 [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
13-Apr-2018 11:00:51.994 信息 [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.45
13-Apr-2018 11:00:52.004 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
13-Apr-2018 11:00:52.013 信息 [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
13-Apr-2018 11:00:52.016 信息 [main] org.apache.catalina.startup.Catalina.start Server startup in 62 ms
Connected to server
[2018-04-13 11:00:52,322] Artifact springmvcdemo5:war exploded: Artifact is being deployed, please wait...
13-Apr-2018 11:00:54.459 信息 [RMI TCP Connection(3)-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.
[2018-04-13 11:00:54,526] Artifact springmvcdemo5:war exploded: Artifact is deployed successfully
[2018-04-13 11:00:54,526] Artifact springmvcdemo5:war exploded: Deploy took 2,205 milliseconds
13-Apr-2018 11:01:02.006 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager
13-Apr-2018 11:01:02.064 信息 [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\manager has finished in 57 ms

.IntelliJIdea2018.1\system\tomcat\Unnamed_springmvcdemo5_2在这里面也没有生成对应的文件?

RISEBY
浏览 604回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java