title: Getting 404 requested resource not available in spring restful web services
body: <p>I'm using spring 3.2.3.RELEASE version and tomcat 7. I wanted to build a sample REST API using spring framework. My web.xml looks something like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfiguration&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/sample-servlet.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;sample-servlet&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;sample&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/myProjects&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>My sample-servlet.xml looks something like this:</p>
  
  <pre><code>&lt;beans&gt;
      &lt;context:component-scan base-package="com.myprojects.sampleproject" /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>Basically I do not want any JSP files since I just want to return string(JSON string) from controller. My controller looks something like this:</p>
  
  <pre><code>package com.myprojects.sampleproject;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  /**
   *
   * @author author
   */
  @Controller
  @RequestMapping("/user")
  public class sampleprojectController {
  
      @RequestMapping(method = RequestMethod.GET)
      public String getHello() {
          return "hello world";
      }
  }
  </code></pre>
  
  <p>I was able to successfully create a war file and deploy it on tomcat. But when I hit localhost:8080/myProjects/user, I get 404. I'm using maven to build and deploy the package.</p>
  
  <p>I've worked on JAX-RS before where in we could configure in netbeans to create a project to write web services and everything came in handy that time. But here I'm actually trying to convert a maven based project to a web application running on tomcat. To do that, I tried this sample and I'm unable to get that up and running. Am I missing something?</p>