title: Spring-MVC: HTTP Status 404 – Not Found
body: <p>I created a simple spring-mvc project using Tomcat v9.0 server to just check if everything is working fine or not. From the main page when I hit the submit button, it is expected to see a message in the console but instead I get following message:</p>
  
  <p><strong>HTTP Status 404 – Not Found</strong></p>
  
  <p>Description: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p>
  
  <p>Here is the code:
  web.xml</p>
  
  <pre><code>&lt;web-app&gt;
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;Spring-MVC&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;Spring-MVC&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>The pom.xml file:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.mvc&lt;/groupId&gt;
    &lt;artifactId&gt;SpringMVC&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;name&gt;SpringMVC Maven Webapp&lt;/name&gt;
    &lt;url&gt;http://maven.apache.org&lt;/url&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;3.8.1&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;4.1.8.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;4.1.8.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;5.1.36&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
    &lt;build&gt;
      &lt;finalName&gt;SpringMVC&lt;/finalName&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  
  </code></pre>
  
  <p>index.jsp:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;form action="add"&gt;
      &lt;input type="text" name="t1"/&gt;&lt;br&gt;
      &lt;input type="text" name="t2"/&gt;&lt;br&gt;
      &lt;input type="submit"/&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>@Controller
  public class AddController {
  
      @RequestMapping("/add")
      public void add() {
          System.out.println("Working!!");
      }
  </code></pre>
  
  <p>Spring-MVC-servlet.xml:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:ctx="http://www.springframework.org/schema/context"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="http://www.springframework.org/schema/beans 
                             http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                             http://www.springframework.org/schema/mvc
                             http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
                             http://www.springframework.org/schema/context
                             http://www.springframework.org/schema/context/spring-context-2.5.xsd "&gt;
      &lt;ctx:annotation-config&gt;&lt;/ctx:annotation-config&gt;
      &lt;ctx:component-scan base-package="com.spring"&gt;&lt;/ctx:component-scan&gt;
  &lt;/beans&gt;
  </code></pre>