0

I'm setting up a simple project with Spring 4. I'm not using Maven. Instead I've simply added the Spring Dependencies by adding the Jars to the classpath. I'm using RAD 8.5 and Websphere 8.5 for this project.

When I am trying to start up the project, it is giving error: class java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

I've provided the following in the web.xml:

<servlet>
        <display-name>Controller</display-name>
        <servlet-name>Controller</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Controller</servlet-name>
        <url-pattern>*</url-pattern>
    </servlet-mapping>

My Controller-servlet.xml looks like:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"  
 xmlns:context="http://www.springframework.org/schema/context"  
 xmlns:p="http://www.springframework.org/schema/p"   
 xmlns:mvc="http://www.springframework.org/schema/mvc"   
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
 xsi:schemaLocation="http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd  
http://www.springframework.org/schema/context  
http://www.springframework.org/schema/context/spring-context-4.0.xsd  
http://www.springframework.org/schema/mvc  
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> 

    <context:component-scan base-package="com.spring4.controller" />
    <bean id="viewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/view/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>  
</beans>

My Controller class looks like:

@Controller
public class HelloSpring4Controller {
    @RequestMapping("/hello")    
      public ModelAndView sayHello() {    
       String message = "Welcome to Spring 4.0 !!! ";    
       return new ModelAndView("welcome", "message", message);    
      } 
}

I have a welcome.jsp under WEB-INF/view where I'm fetching the value put in message Object.

Can someone let me know where I'm going wrong?

Thanks, Sayantani

0 Answers0