title: Spring Security - Redirect to custom login page without going through controller
body: <p>I am currently using Spring Boot + Spring Security to develop a simple website that need user to login to access it. I have created my own custom static login page under <strong>resources/templates1/bruceLogin1.html</strong>. Any unathenticated access to my website to first be redirected to the login page URL which is <a href="http://localhost:8080/templates1/bruceLogin1.html" rel="nofollow noreferrer">http://localhost:8080/templates1/bruceLogin1.html</a></p>
  
  <p>Note: that I am NOT creating any controller for this login URL, hence I am expecting the bruceLogin1.html to be accessed directly bypassing controller. Because i directly allow access to this html page without going thru controller, I assume no view resolver (e.g thymleaf) is required.</p>
  
  <p>I open my browser, and enter <a href="http://localhost:8080/blablabl" rel="nofollow noreferrer">http://localhost:8080/blablabl</a>, and browser redirect me to <a href="http://localhost:8080/templates1/bruceLogin1.html" rel="nofollow noreferrer">http://localhost:8080/templates1/bruceLogin1.html</a> , but sadly, i got error </p>
  
  <pre><code>Whitelabel Error Page
  This application has no explicit mapping for /error, so you are seeing this as a fallback.
  
  Sat Jan 11 12:40:37 SGT 2020
  There was an unexpected error (type=Not Found, status=404).
  No message available
  </code></pre>
  
  <p>Below is my configuration, </p>
  
  <pre><code>
  @SpringBootApplication
  @EnableWebSecurity
  public class SpringSecurityCatalogApplication  implements WebMvcConfigurer {
  
      public static void main(String[] args) {
          SpringApplication.run(SpringSecurityCatalogApplication.class, args);
      }
  
  
  
      @EnableWebSecurity
      @Order(Ordered.HIGHEST_PRECEDENCE)
      class SecurityConfig extends WebSecurityConfigurerAdapter {
          @Override
          protected void configure(HttpSecurity http) throws Exception {
  
               http
               .authorizeRequests()
               .antMatchers("/resources/**").permitAll()
               .anyRequest().authenticated()
               .and()
               .formLogin()
               .loginPage("/templates1/bruceLogin1.html")
               .permitAll();
          }
      }
  
  
  }
  </code></pre>