title: Why Spring RequestMapping not working without @Controller?
body: <p>Sample code I have:</p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;springDispatcher&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;springDispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>springDispatcher-servlet.xml</strong></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-4.0.xsd"&gt;
      &lt;bean id="myController" class="biz.tugay.springWebOne.MyController"/&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>MyController.java</strong></p>
  
  <pre><code>package biz.tugay.springWebOne;
  /* User: koray@tugay.biz Date: 08/07/15 Time: 15:25 */
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  @Controller
  public class MyController {
      @RequestMapping(value = "/hello")
      public String helloWorld(){
          return "index.jsp";
      }
  }
  </code></pre>
  
  <p>Well, everything works fine with this code. However when I remove the</p>
  
  <pre><code> @Controller
  </code></pre>
  
  <p>from <strong>MyController</strong> class I will get: </p>
  
  <pre><code>HTTP ERROR 404
  
  Problem accessing /hello. Reason:
  
      Not Found
  </code></pre>
  
  <p>I am not using <strong>component-scan</strong>, I am using an xml based configuration. Why do I need the @Controller annotation?</p>