Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java DispatcherServlet上的Spring MVC ClassNotFoundException_Java_Spring_Spring Mvc_Servlets - Fatal编程技术网

Java DispatcherServlet上的Spring MVC ClassNotFoundException

Java DispatcherServlet上的Spring MVC ClassNotFoundException,java,spring,spring-mvc,servlets,Java,Spring,Spring Mvc,Servlets,我在运行示例SpringMVCWeb应用程序时遇到上述错误。但是Index.jsp文件正在运行,在此之后,我将得到异常: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 代码如下- web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="htt

我在运行示例SpringMVCWeb应用程序时遇到上述错误。但是Index.jsp文件正在运行,在此之后,我将得到异常:

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
代码如下-

web.xml

<?xml version="1.0" encoding="UTF-8"?>  
<web-app version="2.5"   
    xmlns="http://java.sun.com/xml/ns/javaee"   
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
 <servlet>  
    <servlet-name>spring</servlet-name>  
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
    <load-on-startup>1</load-on-startup>  
</servlet>  
<servlet-mapping>  
    <servlet-name>spring</servlet-name>  
    <url-pattern>*.html</url-pattern>  
</servlet-mapping>  
</web-app> 


我已经编写了一个简单的hellopage.jsp来打印欢迎消息。

确保您的
WEB-INF/lib
文件夹中有spring-webmvc-xx.jar。您使用的是什么IDE?你把JAR文件放在哪里了?我正在使用Eclipse Luna IDE
    <?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:p="http://www.springframework.org/schema/p"  
    xmlns:context="http://www.springframework.org/schema/context"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
http://www.springframework.org/schema/context  
http://www.springframework.org/schema/context/spring-context-3.0.xsd">  
    <context:component-scan  base-package="com.yogesh" />  
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
        <property name="prefix" value="/WEB-INF/jsp/" />  
        <property name="suffix" value=".jsp" />  
    </bean>  
</beans> 
import org.springframework.stereotype.Controller;  
import org.springframework.web.bind.annotation.RequestMapping;  
import org.springframework.web.servlet.ModelAndView;  
@Controller  
public class HelloWorldController {  
    @RequestMapping("/hello")  
    public ModelAndView helloWorld() {  
        String message = "HELLO SPRING MVC HOW R U";  
        return new ModelAndView("hellopage", "message", message);  
    }  
}