How to Solve Springmvc Error: org.springframework.web.servlet.DispatcherServlet

When writing springMVC, after importing all required packages, run the program, the console reports the following error:

Critical: Servlet [springDispatcherServlet] in web application [/SpringMVC-1 ] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java: 1333 )
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java: 1167 )
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java: 518 )
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java: 499 )
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java: 118 )
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java: 1091 )
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java: 1027 )
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java: 5038 )
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java: 5348 )
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java: 145 )
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java: 725 )
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java: 701 )
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java: 717 )
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java: 587 )
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java: 1798 )
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

You can’t import org.springframework.web.servlet.DispatcherServlet in a java file. This class is mainly under the spring-webmvc jar package. All imported jar packages are as follows:

All have been imported, there is no problem. But in fact, all dependencies must be added to the classpath. step:

Right-click the project–>properties–>Deployment Assembly–>add–>Java Build Path Entries–>import all dependent Jar packages and restart tomcat.

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *