title: Spring 405 error for POST method
body: <p>I'm trying to secure my website using Spring security following the guides on the web. I don't want my users to use my application through web browsers, so I disabled the csrf protection. The source code on the server side:</p>
  
  <pre><code>    @Configuration
  @EnableWebSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter
  implements ApplicationContextAware {
  
  @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
          .authorizeRequests().anyRequest().authenticated().and()
          .httpBasic().and()
          .csrf().disable();
      }
  
  @Override
  protected void registerAuthentication(AuthenticationManagerBuilde r authManagerBuilder) throws Exception {
  authManagerBuilder.inMemoryAuthentication()
  .withUser("user").password("password").roles("ADMI N");
  }
  }
  
  @Controller
  //@RequestMapping("/course")
  public class CourseController implements ApplicationContextAware{
  
  @RequestMapping(value="/course", method = RequestMethod.GET, produces="application/json")
  public @ResponseBody List&lt;Course&gt; get(// The critirion used to find.
  @RequestParam(value="what", required=true) String what,
  @RequestParam(value="value", required=true) String value) {
  //.....
  }
  
  @RequestMapping(value="/course", method = RequestMethod.POST, produces="application/json")
  public List&lt;Course&gt; upload(@RequestBody Course[] cs) {
  }
  }
  </code></pre>
  
  <p>I am using RestTemplate on the client side. The problem is that when I use POST method, I got warinning on the server side:
          o.s.web.servlet.PageNotFound             : Request method 'POST' not supported</p>
  
  <p>And on the client side, I got:
          Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 405 Method Not Allowed</p>
  
  <p>It is odd I got this exception because I already have the POST method handled in the Controller. Currently, the system still works, but this issue bothers me.
  Any idea?
  Thanks.</p>