title: Spring 4 Rest service 404 Error
body: <p>I am learning spring 4 mvc and creating a simple web app. I have a Spring 4 backend with REST endpoints to hit from my AngularJS front end. The problem is whenever I hit these endpoints from my front end the request returns a 404.</p>
  
  <p>Here's my Spring configuration files</p>
  
  <p><strong><em>web.xml</em></strong></p>
  
  <pre><code>&lt;!DOCTYPE web-app PUBLIC
   "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd" &gt;
  
  &lt;web-app&gt;
    &lt;display-name&gt;Archetype Created Web Application&lt;/display-name&gt;
  
  
    &lt;!-- Spring MVC --&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;mvc-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;mvc-dispatcher&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong><em>mvc-dispatcher-servlet.xml</em></strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    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.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.2.xsd"&gt;
  
    &lt;bean
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix"&gt;
        &lt;value&gt;/WEB-INF/pages/&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="suffix"&gt;
        &lt;value&gt;.jsp&lt;/value&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong><em>loginController.java</em></strong></p>
  
  <pre><code>package controller;
  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RestController;
  
  
  
  @RestController
  public class loginController {
  
  
  
      @RequestMapping(value = "/user", method = RequestMethod.GET)
      public String listAllUsers() {
          return "test";
  
      }
  }
  </code></pre>
  
  <p>I've tried changing my configuration a lot of different ways but nothing seems to work. What could be causing the problem here?</p>