title: Spring : Responding to a REST-ful API call
body: <p>I am trying to implement REST API endpoints in y application.</p>
  
  <pre><code>@Controller
   public class HerokuController {
  
      @RequestMapping(value = "/heroku/resources/", method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
      public  ResponseEntity&lt;JSONObject&gt; provision(@RequestBody JSONObject body){
          System.out.println("called! \n");
          JSONObject response = new JSONObject();
          response.put("id", 555);
          response.put("message", "Provision successful!");
            return new ResponseEntity&lt;JSONObject&gt;(response,HttpStatus.OK);        
      }
  </code></pre>
  
  <p>So I wrote this class containing a method which mapping is (heroku/ressources).
  But when I try to call it, I get a 404 error because <code>/WEB-INF/heroku/resources.jsp</code> not found. However, I don't even want to get a view but a HTTP response.</p>
  
  <p>Can anyone tell me which configuration file should we generally modify to tell Spring that this controller doesn't want to send back a view but a HTTP response?</p>
  
  <p>The method is however called if I change it to this :</p>
  
  <pre><code>@RequestMapping(value = "/heroku/resources/", method = RequestMethod.POST)
      public  ModelAndView provision(final HttpServletRequest request){
              System.out.println("called! \n");
              JSONObject response = new JSONObject();
              response.put("id", 555);
              response.put("message", "Provision successful!");
              final Map&lt;String, Object&gt; result = new HashMap&lt;String, Object&gt;();
            return new ModelAndView("jsonView",result);   
      }
  </code></pre>
  
  <p>So changing the return type to <code>"ModelAndView"</code>.</p>
  
  <p>thanks.</p>