title: Spring security authentication without spring boot doesn't work as opposed to with spring boot and similar configuration
body: <h2>With Spring Boot:</h2>
  <p>The working Spring Boot + Spring Security application uses this for request mapping:</p>
  <pre><code>@SpringBootApplication
  public class SampleLDAPApplication extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          SpringApplication.run(SampleLDAPApplication.class, args);
      }
  
      @Bean
      public WebMvcConfigurerAdapter adapter() {
          return new WebMvcConfigurerAdapter() {
              @Override
              public void addViewControllers(ViewControllerRegistry registry) {
                  registry.addViewController(&quot;/login&quot;)
                      .setViewName(&quot;login&quot;);
              }
          };
      }
  
  }
  </code></pre>
  <p>This is the security configuration:</p>
  <pre><code>@Configuration
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  
          auth.ldapAuthentication().userSearchBase(&quot;ou=Users&quot;).userSearchFilter(&quot;(uid={0})&quot;)
                  .groupSearchBase(&quot;ou=bla,ou=Roles&quot;).groupSearchFilter(&quot;(roleOccupant={0})&quot;)
                  .contextSource().root(&quot;dc=ops,dc=blabla,dc=com&quot;).url(&quot;ldap://192.168.1.57:389/dc=ops,dc=blabla,dc=com&quot;);
      }
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.authorizeRequests().antMatchers(&quot;/&quot;, &quot;/home&quot;).permitAll().anyRequest().authenticated();
          http.formLogin().loginPage(&quot;/login&quot;).permitAll().and().logout().logoutSuccessUrl(&quot;/&quot;);
      }
  }
  </code></pre>
  <p>And this is the login page:</p>
  <pre><code>&lt;div class=&quot;content&quot;&gt;
      &lt;h2&gt;Login with Username and Password&lt;/h2&gt;
      &lt;form name=&quot;form&quot; th:action=&quot;@{/login}&quot; method=&quot;POST&quot;&gt;
          &lt;fieldset&gt;
              &lt;input type=&quot;text&quot; name=&quot;username&quot; value=&quot;&quot; placeholder=&quot;Username&quot; /&gt;
              &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; /&gt;
          &lt;/fieldset&gt;
          &lt;input type=&quot;submit&quot; id=&quot;login&quot; value=&quot;Login&quot;/&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Whenever I go to the reserved <code>/secure</code> URL, the application correctly redirects me to the login page for authentication.</p>
  <h2>Without Spring Boot:</h2>
  <p>My Spring Security web application without Spring Boot uses the following controller for request mapping:</p>
  <pre><code>@Controller
  @RequestMapping(&quot;/&quot;)
  public class UserController {
      @RequestMapping(value = &quot;login&quot;)
      public String login() {
          return &quot;login&quot;;
      }
  }
  </code></pre>
  <p>The security configuration is completely the same as in the case of Spring Boot application, the only difference being the additional <code>@EnableWebSecurity</code> annotation.</p>
  <p>The only difference in the view section of my application without Spring Boot is that I use JSP instead of Thymeleaf as in the case of Spring Boot:</p>
  <pre><code>&lt;form action=&quot;/login&quot; method=&quot;POST&quot;&gt;
      &lt;fieldset&gt;
          &lt;input type=&quot;text&quot; name=&quot;username&quot; value=&quot;&quot; placeholder=&quot;Username&quot; /&gt;
          &lt;input type=&quot;password&quot; name=&quot;password&quot; placeholder=&quot;Password&quot; /&gt;
      &lt;/fieldset&gt;
      &lt;input type=&quot;submit&quot; id=&quot;login&quot; value=&quot;Login&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>But now when I go to <code>/secure</code>, my application incorrectly serves me this page instead of redirecting to the login page. Why is that so?</p>