0

I created a Dynamic Project in Eclipse, but when I opened, it was throwing ClassNotFound exception that is "Servlet [HelloWorld] in web application [/HelloWorld] threw load() exception java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet" from server. It's simple project - HelloWorld. This is my web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://xmlns.jcp.org/xml/ns/javaee"  
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"      
             id="WebApp_ID" version="3.1">
    <display-name>HelloWorld</display-name>
    <welcome-file-list>
       <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
       <servlet-name>HelloWorld</servlet-name>
       <servlet-class>
           org.springframework.web.servlet.DispatcherServlet
       </servlet-class>      
       <load-on-startup>1</load-on-startup>
    </servlet>

   <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>*.html</url-pattern>
   </servlet-mapping>
 </web-app>

This is HelloWorld-servlet.xml:

   <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="controller">
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="caseSensitive" value="true"></property>
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView">
            <property name="prefix" value="/WEB-INF/jsp/">
                <property name="suffix" value=".jsp">
                </property>
            </property>
        </property>
    </bean>
</context:component-scan>
</beans>

This is redirect.jsp:

   <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
   <% response.sendRedirect("hello.html");%>

This is helloworldcontroller.java

    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.servlet.ModelAndView;

    @Controller
    public class helloworldcontroller {

   @RequestMapping(value="/hello")
   public ModelAndView index(ModelMap m)
   {
    String mss = "Hello World";
    return new ModelAndView("hello", "ms", mss);
   }
   }

When I import some projects of another people that it run with no exception. But I create new project following step by step it's always throw exception. That make me crazy. I need to help. Thanks!

0 Answers0