title: how to configure web.xml for spring
body: <p>I am new to spring Framework and having problem with linking/configuring springframework through web.xml. 
  I am getting below error when running my app.</p>
  
  <p>Error:</p>
  
  <pre><code>HTTP Status 500 - Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
  
  
      type Exception report
  
      message Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
  
      description The server encountered an internal error (Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet) that prevented it from fulfilling this request.
  
      exception 
  
      javax.servlet.ServletException: Error instantiating servlet class org.springframework.web.servlet.DispatcherServlet
          org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
          org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
          org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
          org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
          org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
          java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          java.lang.Thread.run(Unknown Source)
  
  
      root cause 
  
      java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
          org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)
          org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)
          org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
          org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
          org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
          org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
          org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
          org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
          org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
          java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
          java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
          java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Apparently, it could not find class org.springframework.web.servlet.DispatcherServlet in the Libraries. However, I dont know how to tell web.xml where to look for this class.</p>
  
  <p>web.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns="http://java.sun.com/xml/ns/javaee" 
               xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
               xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
  
          &lt;servlet&gt;
              &lt;servlet-name&gt;DispatcherSample&lt;/servlet-name&gt;
              &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;/servlet&gt;
  
          &lt;servlet-mapping&gt;
              &lt;servlet-name&gt;DispatcherSample&lt;/servlet-name&gt;
              &lt;url-pattern&gt;/PlayField.html&lt;/url-pattern&gt;
          &lt;/servlet-mapping&gt;
  
        &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
          &lt;welcome-file&gt;Welcome.html&lt;/welcome-file&gt;
        &lt;/welcome-file-list&gt;
  
      &lt;/web-app&gt;
  </code></pre>
  
  <p>DispatcherSample-servlet.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
      &lt;beans xmlns="http://www.springframework.org/schema/beans"
          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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
          &lt;bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"&gt;  
              &lt;property name="mappings"&gt;
                  &lt;props&gt;
                      &lt;prop key="/PlayField.html"&gt;playfieldController&lt;/prop&gt;
                  &lt;/props&gt;    
              &lt;/property&gt;
          &lt;/bean&gt;
  
          &lt;bean id="playfieldController" class="demos.PlayfieldController"/&gt;
  
      &lt;/beans&gt;
  </code></pre>