title: How can I make welcome-file-list work with Spring Servlet?
body: <p>This is the code I have:</p>
  
  <pre><code>public class Bootstrap implements WebApplicationInitializer {
  
      @Override
      public void onStartup(ServletContext container) throws ServletException {
  
          container.getServletRegistration("default").addMapping("/resources/*");
  
          AnnotationConfigWebApplicationContext servletContext =
                  new AnnotationConfigWebApplicationContext();
          servletContext.register(ServletContextConfiguration.class);
  
          ServletRegistration.Dynamic dispatcher =
                  container.addServlet("springDispatcher", new DispatcherServlet(servletContext));
  
          dispatcher.setLoadOnStartup(1);
          dispatcher.addMapping("/");
      }
  }
  </code></pre>
  
  <p>moving on: </p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan(
          basePackages = "biz.tugay.booksspringone.controller",
          useDefaultFilters = false,
          includeFilters = @ComponentScan.Filter(Controller.class)
  )
  public class ServletContextConfiguration {
  
      @Bean
      public ViewResolver viewResolver() {
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix("/WEB-INF/views/");
          resolver.setSuffix(".jsp");
          resolver.setExposeContextBeansAsAttributes(true);
          return resolver;
      }
  
  }
  </code></pre>
  
  <p>and web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
           http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
           version="3.0"&gt;
  
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;/welcome&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and my controller:</p>
  
  <pre><code>@Controller
  public class HelloController {
      @RequestMapping(value = "/welcome", method = RequestMethod.GET)
      public ModelAndView welcome() {
          ModelAndView modelAndView = new ModelAndView();
          modelAndView.setViewName("welcome");
          return modelAndView;
      }
  }
  </code></pre>
  
  <p>When I deploy my app and navigate to localhost:8080/ I expect <strong>HelloController.welcome</strong> to be called, but it is not.</p>
  
  <p>The method is called only if I explicitly visit <strong><a href="http://localhost:8080/welcome" rel="nofollow">http://localhost:8080/welcome</a></strong></p>
  
  <p>How can I fix this?</p>