title: Spring Boot Application Null ModelAndView returned
body: <p>I have developed a spring boot (1.5.1.RELEASE) application using Java 1.8. I am using spring security with a custom user details services. </p>
  
  <p>On successful authentication my application is not displaying the correct html page/view, it remains at the login page - this is what I see in the logs:</p>
  
  <pre><code>2017-12-15 23:19:43.998 DEBUG 10340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
  2017-12-15 23:19:43.998 DEBUG 10340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
  </code></pre>
  
  <p>This is something that I have done many times before but for some reason this time it isn't working and I can't figure out why, so I'm looking for some help.</p>
  
  <p>This is my security config class:</p>
  
  <pre><code>@Configuration
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
  /** The Constant LOGIN_PAGE. */
  private static final String LOGIN_PAGE = "/login";
  
  /** The Constant AUTHORISED_REQUESTS_ANT_MATCHER. */
  private static final String AUTHORISED_REQUESTS_ANT_MATCHER = "/**";
  
  /** The Constant BAD_CREDENTIALS_EXCEPTION_URL. */
  private static final String BAD_CREDENTIALS_EXCEPTION_URL = "/login?error";
  
  /** The Constant ACCOUNT_EXPIRED_EXCEPTION_URL. */
  private static final String ACCOUNT_EXPIRED_EXCEPTION_URL = "/login?accountexpired";
  
  /** The Constant CREDENTIALS_EXPIRED_EXCEPTION_URL. */
  private static final String CREDENTIALS_EXPIRED_EXCEPTION_URL = "/login?credentialsexpired";
  
  /** The Constant ACCOUNT_DISABLED_EXCEPTION_URL. */
  private static final String ACCOUNT_DISABLED_EXCEPTION_URL = "/login?accountdisabled";
  
  /** The Constant ACCOUNT_LOCKED_EXCEPTION_URL. */
  private static final String ACCOUNT_LOCKED_EXCEPTION_URL = "/login?accountlocked";
  
  /** The find user by username command. */
  @Autowired
  private Command&lt;FindUserByUsernameResp, FindUserByUsernameParam&gt; findUserByUsernameCommand;
  
  public SecurityConfig() {
      super();
  }
  
  // ===========================================
  // Public Methods
  // ===========================================
  
  public Command&lt;FindUserByUsernameResp, FindUserByUsernameParam&gt; getFindUserByUsernameCommand() {
      return findUserByUsernameCommand;
  }
  
  public void setFindUserByUsernameCommand(Command&lt;FindUserByUsernameResp, FindUserByUsernameParam&gt; findUserByUsernameCommand) {
      this.findUserByUsernameCommand = findUserByUsernameCommand;
  }
  
  @Bean
  public ExceptionMappingAuthenticationFailureHandler exceptionMappingAuthenticationFailureHandler() {
      Map&lt;String, String&gt; mappings = new HashMap&lt;String, String&gt;();
      mappings.put(BadCredentialsException.class.getCanonicalName(), BAD_CREDENTIALS_EXCEPTION_URL);
      mappings.put(AccountExpiredException.class.getCanonicalName(), ACCOUNT_EXPIRED_EXCEPTION_URL);
      mappings.put(CredentialsExpiredException.class.getCanonicalName(), CREDENTIALS_EXPIRED_EXCEPTION_URL);
      mappings.put(DisabledException.class.getCanonicalName(), ACCOUNT_DISABLED_EXCEPTION_URL);
      mappings.put(LockedException.class.getCanonicalName(), ACCOUNT_LOCKED_EXCEPTION_URL);
  
      ExceptionMappingAuthenticationFailureHandler exceptionMappingAuthenticationFailureHandler = new ExceptionMappingAuthenticationFailureHandler();
      exceptionMappingAuthenticationFailureHandler.setExceptionMappings(mappings);
      return exceptionMappingAuthenticationFailureHandler;
  }
  
  @Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.userDetailsService(new UserDetailsServiceImpl(getFindUserByUsernameCommand()));//.passwordEncoder(new BCryptPasswordEncoder());
  }
  
  protected void configure(HttpSecurity http) throws Exception {
      http.formLogin().loginPage(LOGIN_PAGE).successForwardUrl("/")
          .and()
          .authorizeRequests()
          .antMatchers(LOGIN_PAGE).permitAll()
          .antMatchers(AUTHORISED_REQUESTS_ANT_MATCHER).authenticated();
  }
  
  
  }
  </code></pre>
  
  <p>And this is my web configuration:</p>
  
  <pre><code>@Configuration
  public class WebConfig extends WebMvcConfigurerAdapter {
  
  // ===========================================
  // Public Members
  // ===========================================
  
  // ===========================================
  // Private Members
  // ===========================================
  
  /** The Constant ROOT_URL. */
  private static final String ROOT_URL = "/";
  
  /** The Constant ROOT_VIEW. */
  private static final String ROOT_VIEW = "app/views/index";
  
  /** The Constant LOGIN_URL. */
  private static final String LOGIN_URL = "/login";
  
  /** The Constant LOGIN_VIEW. */
  private static final String LOGIN_VIEW = "login";
  
  /*
   * (non-Javadoc)
   *
   * @see
   * org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
   * #addViewControllers(org.springframework.web.servlet.config.annotation.
   * ViewControllerRegistry)
   */
  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
      registry.addViewController(ROOT_URL).setViewName(ROOT_VIEW);
      registry.addViewController(LOGIN_URL).setViewName(LOGIN_VIEW);
  }
  
  }
  </code></pre>
  
  <p>I have two html pages in my application, under the templates folder, and they are:</p>
  
  <p>login.html (which displays fine)
  app/views/index.html</p>
  
  <p>My index.html file never gets displayed.</p>
  
  <p>Any ideas?</p>