title: Spring Security Custom Login Error
body: <p>I have been trying to add Spring Security Custom Login(Java Config) into my application, but a strange error keeps popping up.</p>
  
  <p>I have gone through the <a href="http://docs.spring.io/autorepo/docs/spring-security/3.2.x/guides/form.html" rel="noreferrer">Creating a Custom Login Form tutorial</a> and it works just fine. I am not sure what is the issue with my application.</p>
  
  <p><strong>Error</strong></p>
  
  <blockquote>
    <p>Caused by: java.lang.IllegalArgumentException: 'login?error' is not a
    valid redirect URL</p>
  </blockquote>
  
  <p><strong>Security Config</strong></p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      @Autowired
      public void configure(AuthenticationManagerBuilder auth)
              throws Exception {
          auth
          .inMemoryAuthentication()
              .withUser("user").password("password").roles("USER");
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests().antMatchers("/", "/about").permitAll();
          http
          .authorizeRequests()
          .antMatchers("/admin","/admin/**").hasRole("ADMIN")
          .anyRequest().authenticated()
          .and()
          .formLogin()
          .loginPage("login")
          .permitAll();
      }
  }
  </code></pre>
  
  <p><strong>LoginController</strong></p>
  
  <pre><code>@Controller
  public class LoginController {
  
      @RequestMapping(value = "login", method = RequestMethod.GET)
      public String loginView() {
          return "login";
      }
  
      @RequestMapping(value = "login", method = RequestMethod.POST)
      public String login(@ModelAttribute Login login) {
          return "home";
      }
  }
  </code></pre>
  
  <p>Just commenting the method <code>configure(HttpSecurity http)</code> removes the exception. I tried adding <code>RequestMapping</code> with value <code>login?error</code>, but it didn't help. What am I missing here?</p>
  
  <p><a href="http://hastebin.com/ekerawituh.sm" rel="noreferrer">Link to complete stack trace</a></p>