title: SpringMVC (Security) - 403 error
body: <p>I'm developing a simple Java web application with SpringMVC. With security enabled, I cannot send a HTTP post request (from the index.jsp) to the server although I am already authenticated. POST request does work when the security isn't implemented. So I think it's a problem with my <code>SecurityConfig.java</code> code.Could you please help me with this? Thanks very much</p>
  
  <p>Error Code :</p>
  
  <pre><code>HTTP Status 403 – Forbidden
  
  Type Status Report
  
  Message Forbidden
  
  Description The server understood the request but refuses to authorize it.
  </code></pre>
  
  <p>This is my security configuration. </p>
  
  <p>SecurityConfig.java</p>
  
  <pre><code> import org.springframework.beans.factory.annotation.Autowired;
   import org.springframework.context.annotation.Configuration;
   import org.springframework.http.HttpMethod;
   import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
   import org.springframework.security.config.annotation.web.builders.HttpSecurity;
   import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
   import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  
   @Configuration
   @EnableWebSecurity
   public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
       @Autowired
       public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
              auth.inMemoryAuthentication().withUser("user1").password("{noop}123456").roles("USER");
  
          }
  
          @Override
          protected void configure(HttpSecurity http) throws Exception {
  
              http
                      .formLogin()
                      .and()
                      .authorizeRequests()
                      .antMatchers("/index").hasRole("USER")
                      .antMatchers(HttpMethod.POST, "/index").hasRole("USER");
  
          }
      }
  </code></pre>
  
  <p>index.jsp</p>
  
  <pre><code>&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;META http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Registration&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
       &lt;form action='@{/index}' method="POST"&gt;
       &lt;div class="form-group"&gt;
  
       &lt;td&gt;&lt;textarea class="form-control" name="textForm"&gt;${text1}&lt;/textarea&gt;   
       &lt;input type="submit" value="Submit"&gt;
       &lt;textarea name="textFin"&gt;${textFinal}&lt;/textarea&gt;&lt;/td&gt;
       &lt;/form&gt;
      &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>