title: Can't login to my custom login page in spring boot security
body: <p>My problem is: when I try to login on my custom login page it redirects me to login page again (it doesn't matter if I put right or wrong credentials). It's also weird that I don't reach my custom UserDetailService in debug, I think it means that spring doesn't even check user's credentials.</p>
  
  <p>I have custom login form <code>/WEB-INF/jsp/login.jsp</code>:</p>
  
  <pre><code>...    
  &lt;form name='loginForm' action="&lt;c:url value='j_spring_security_check' /&gt;" method='POST'&gt;
  
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td&gt;User:&lt;/td&gt;
                  &lt;td&gt;&lt;input type='text' name='j_username' value=''&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td&gt;Password:&lt;/td&gt;
                  &lt;td&gt;&lt;input type='password' name='j_password' /&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan='2'&gt;&lt;input name="submit" type="submit"
                                         value="submit" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;input type="hidden" name="${_csrf.parameterName}"
                 value="${_csrf.token}" /&gt;
  
      &lt;/form&gt;
  ...
  </code></pre>
  
  <p>This is configuration:</p>
  
  <pre><code>@Configuration
  @EnableWebMvcSecurity
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private UserDetailsService userDetailsService;
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .authorizeRequests().antMatchers("/", "/welcome", "/resources/**").permitAll()
                  .anyRequest().authenticated().and()
                  .formLogin().loginPage("/login").failureUrl("/login?error").permitAll().and()
                  .logout().logoutUrl("/login?logout").permitAll();
      }
  
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
      }
  
      @Bean
      public PasswordEncoder passwordEncoder() {
          return new BCryptPasswordEncoder();
      }
  }
  </code></pre>
  
  <p>And this is inside controller:</p>
  
  <pre><code>@RequestMapping(value = "/login", method = RequestMethod.GET)
  public ModelAndView login(
          @RequestParam(value = "error", required = false) String error,
          @RequestParam(value = "logout", required = false) String logout) {
  
      ModelAndView model = new ModelAndView();
      if (error != null) {
          model.addObject("error", "Invalid username and password!");
      }
  
      if (logout != null) {
          model.addObject("msg", "You've been logged out successfully.");
      }
      model.setViewName("login");
  
      return model;
  
  }
  </code></pre>
  
  <p>In <code>src/main/resources/application.properties</code> I have:</p>
  
  <pre><code>spring.view.prefix: /WEB-INF/jsp/
  spring.view.suffix: .jsp
  </code></pre>