title: Spring: Request method 'PUT' not supported
body: <p>I started with one of the Spring getting started samples. I am extending it to match my scenario. I am trying to use the PUT method on a web service call. I get the error message "Request method 'PUT' not supported". But, execution makes it into the web service. The error occurs after/during returning. Is there something I need to do to my objects to allow the to be returned from non-GET HTTP methods?</p>
  
  <p>I am calling into the web service with a test stub written in python. I have not posted that code since execution is getting into the web service.</p>
  
  <p>Following is the Spring code:</p>
  
  <pre><code>@ComponentScan
  @EnableAutoConfiguration
  @Controller
  @RequestMapping("/jp5/rest/message")
  public class MessageRestService
  {
     @RequestMapping(method=RequestMethod.PUT, value="/test")
     public testResult test()
     {
         // I hit a breakpoint here:
         return new testResult(true, "test");
     }
  }
  
  class testResult
  {
  
      public testResult( boolean success, String message )
      {
          setSuccess(success);
          setMessage(message);
      }
  
      //@XmlElement
      private boolean success;
  
      //@XmlElement
      private String message;
  
      public boolean isSuccess() {
          return success;
      }
  
      public void setSuccess(boolean success) {
          this.success = success;
      }
  
      public String getMessage() {
          return message;
      }
  
      public void setMessage(String message) {
          this.message = message;
      }
  }
  </code></pre>
  
  <p><strong>Edit</strong>
  There is no stack trace, just this in the server output:</p>
  
  <pre><code>2013-11-13 21:26:20.976  WARN 5452 --- [nio-8888-exec-1] 
               o.s.web.servlet.PageNotFound             : 
               Request method 'PUT' not supported
  </code></pre>
  
  <p>Here is the python as requested. And, I think the answer to the problem lies in <strong>"'allow': 'GET, HEAD'"</strong> in the response. So, how do I allow other methods? Maybe I need to think about an applicationContext?</p>
  
  <pre><code>    path = '/jp5/rest/message/test'
      method = 'PUT'
      body = ''
  
      target = urlparse(self.uri+path)
  
      h = http.Http()
  
      headers = {
                       'Accept': 'application/json',
                       'Content-Type': 'application/json; charset=UTF-8'
                     }        
      response, content = h.request(
              target.geturl(),
              method,
              body,
              headers)
      print response
  </code></pre>
  
  <p>output from the print:</p>
  
  <pre><code>{'status': '405', 'content-length': '1045', 'content-language': 'en-US', 'server':
  'Apache-Coyote/1.1', 'allow': 'GET, HEAD', 'date': 'Thu, 14 Nov 2013 02:26:20 GMT', 
   'content-type': 'text/html;charset=utf-8'}
  </code></pre>
  
  <p>I am starting the server like this:</p>
  
  <pre><code>@ComponentScan
  @EnableAutoConfiguration
  
  public class Application {
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  
  <p>Thanks</p>