简体   繁体   中英

Spring MVC + Eclipse: HTTP 404 – Not Found

Problem summary

I've created a basic Spring MVC application in Eclipse, and manually added the Spring JARs to the lib. I'm using XML configs. It returns a 404 error when I run it. The WARN output in my console tells me WARNING: No mapping for GET /Spring-MVC-Demo/

What I've tried

  1. My web.xml file has the <absolute-ordering /> tag as suggested in other answers to similar questions.

  2. I've also updated the <context:component-scan base-package="com.demo.springdemo.mvc" /> to reflect my own src package name, as suggested in another answer to a similar question.

I understand that the console WARN is pretty explicit in telling me what's wrong, but I just don't know how else to fix it.

Here is the source code

https://drive.google.com/drive/folders/1GTuRmBdIugvQT-8OxW4g-EcdHdRAsj49?usp=sharing

Console Output:

Feb 14, 2021 8:43:49 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version name:   Apache Tomcat/9.0.43
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built:          Jan 28 2021 20:25:45 UTC
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version number: 9.0.43.0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name:               Windows 10
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version:            10.0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture:          amd64
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jre1.8.0_271
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version:           1.8.0_271-b09
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor:            Oracle Corporation
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE:         C:\Users\odubh\Workspace_Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 9.0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=C:\Users\odubh\Workspace_Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=C:\Users\odubh\Workspace_Eclipse\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 9.0\endorsed
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=UTF-8
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: Loaded Apache Tomcat Native library [1.2.26] using APR version [1.7.0].
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized [OpenSSL 1.1.1i  8 Dec 2020]
Feb 14, 2021 8:43:50 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Feb 14, 2021 8:43:50 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [948] milliseconds
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Catalina]
Feb 14, 2021 8:43:50 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.43]
Feb 14, 2021 8:43:51 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
Feb 14, 2021 8:43:51 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring DispatcherServlet 'dispatcher'
Feb 14, 2021 8:43:51 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Initializing Servlet 'dispatcher'
Feb 14, 2021 8:43:52 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: Completed initialization in 1335 ms
Feb 14, 2021 8:43:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Feb 14, 2021 8:43:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [2323] milliseconds
Feb 14, 2021 8:43:53 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping for GET /Spring-MVC-Demo/

Versions

Tomcat: 9.0

Eclipse: 2020-12 (4.18.0)

JDK: 1.8.0_271

I had a typo in naming my "main-menu.jsp". I accidently called it "main-manu.jsp". This question may be of no use to anyone other than to say check your spellings on filenames.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM