title: 404 error when calling Spring controller method from Angular $http
body: <p>I have been trying to run a sample Single Page Application that uses Spring 4.2.5 along with AngularJs. I am trying to call one of my methods in Controller from Angular's <code>$http</code> service. </p>
  
  <p><strong>Inside some controller:</strong></p>
  
  <pre><code>$scope.goTosearchList = function() {
          $http.get("/rest/getSearchList").success(function(data){
              $scope.data=data;
              alert("success "+data);
          })
          $location.path("/rest/searchList");
      };
  </code></pre>
  
  <p><strong>Trying to catch this request in a controller:</strong> </p>
  
  <pre><code>@Controller
  
  public class MyPortController {
  
      @Autowired
      DatabaseDao dao;
  
      @RequestMapping(value="/getSearchList",method=RequestMethod.GET)
      public void searchbyid() {
  
          System.out.println("hello, we r in java");
          dao.databaseConnect();
  
      }
  
  }
  </code></pre>
  
  <p><strong>web.xml</strong>:</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://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"&gt;
    &lt;display-name&gt;MyPort&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  
    &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt; org.springframework.web.servlet.DispatcherServlet &lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/rest/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>Here is my spring servlet:</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"
         xmlns:p="http://www.springframework.org/schema/p"
         xmlns:context="http://www.springframework.org/schema/context"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         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
                             http://www.springframework.org/schema/mvc
                             http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
      &lt;context:component-scan base-package="com.mmt.controller" /&gt;
      &lt;mvc:annotation-driven&gt;&lt;/mvc:annotation-driven&gt;
     &lt;!--  &lt;bean id="searchbyid" class="com.mmt.dao.DatabaseDao"&gt;
      &lt;/bean&gt; --&gt;
  
      &lt;/beans&gt;
  </code></pre>
  
  <p>Issue may sound a bit naive, but I do am not able to find a way out. Please help me.</p>