title: Unable to map to Spring controller when using / but it can with /*
body: <p>I'm trying to configure Spring MVC using only java configuration by extending <code>AbstractAnnotationConfigDispatcherServletInitializer</code> and <code>WebMvcConfigurerAdapter</code> but I'm having problems getting my requests to map correctly to my application. It seems to be a subtle problem with the servlet mapping in <code>getServletMappings()</code>. If I specify "/" I simply cannot reach my controller class at all; there are no errors. If I use "/*" then I can reach the controller but the view is not resolved correctly (something perhaps to do with the context path being appended):</p>
  
  <pre><code>WARN  [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/my-project/WEB-INF/views/welcome.jsp] in DispatcherServlet with name 'dispatcher'
  </code></pre>
  
  <p>I'm using the URL:</p>
  
  <pre><code>http://localhost:8080/my-project/welcome
  </code></pre>
  
  <p>Here are my classes:</p>
  
  <pre><code>public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  
      @Override
      protected Class&lt;?&gt;[] getRootConfigClasses() {
          return new Class[] { RootConfig.class};
      }
  
      @Override
      protected Class&lt;?&gt;[] getServletConfigClasses() {
          return new Class[] { WebMvcConfig.class };
      }
  
      @Override
      protected String[] getServletMappings() {
          return new String[] { "/*" }; // Using only "/" doesn't appear to work
      }
  
      @Override
      protected Filter[] getServletFilters() {
          CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
          characterEncodingFilter.setEncoding("UTF-8");
          return new Filter[] { characterEncodingFilter };
      }
  }
  </code></pre>
  
  <p>The MVC configuration:</p>
  
  <pre><code>@Configuration
  @EnableWebMvc
  @ComponentScan(basePackages = { "com.myproject.controller" })
  public class WebMvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
      }
  
      @Bean
      public ViewResolver viewResolver() {
          InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
          viewResolver.setPrefix("/WEB-INF/views/");
          viewResolver.setSuffix(".jsp");
          return viewResolver;
      }
  }
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>@Controller
  public class BaseController {
  
      @RequestMapping(value = { "/", "/welcome" }, method = RequestMethod.GET)
      public String welcome(ModelMap model) {
          // welcome.jsp
          return "welcome";
      }
  }
  </code></pre>
  
  <p>The server startup logs: (I'm using JBoss 7.1)</p>
  
  <pre><code>09:37:24,440 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-10) Root WebApplicationContext: initialization started
  09:37:24,441 INFO  [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-10) Refreshing Root WebApplicationContext: startup date [Tue Jan 07 09:37:24 CET 2014]; root of context hierarchy
  09:37:24,474 INFO  [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-10) Registering annotated classes: [class com.myproject.configuration.WebSecurityConfiguration,class com.myproject.configuration.RootConfig]
  09:37:24,632 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-10) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
  09:37:25,750 INFO  [stdout] (MSC service thread 1-10) Error :  91
  
  09:37:26,753 INFO  [stdout] (MSC service thread 1-10) Error :  91
  
  09:37:26,847 INFO  [org.springframework.security.web.DefaultSecurityFilterChain] (MSC service thread 1-10) Creating filter chain: Ant [pattern='/resources/**'], []
  09:37:26,891 INFO  [org.springframework.security.web.DefaultSecurityFilterChain] (MSC service thread 1-10) Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@2adf45ef, org.springframework.security.web.context.SecurityContextPersistenceFilter@79a4f1de, org.springframework.security.web.header.HeaderWriterFilter@3036c16f, org.springframework.security.web.csrf.CsrfFilter@52f9c83e, org.springframework.security.web.authentication.logout.LogoutFilter@2ad7d56d, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@21d18342, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@2a83402, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3626e2d2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@286863e6, org.springframework.security.web.session.SessionManagementFilter@7480c96b, org.springframework.security.web.access.ExceptionTranslationFilter@4ff59f9e, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4ba78535]
  09:37:26,911 INFO  [org.springframework.web.context.ContextLoader] (MSC service thread 1-10) Root WebApplicationContext: initialization completed in 2470 ms
  09:37:26,917 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/my-project]] (MSC service thread 1-10) Initializing Spring FrameworkServlet 'dispatcher'
  09:37:26,918 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-10) FrameworkServlet 'dispatcher': initialization started
  09:37:26,922 INFO  [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-10) Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Tue Jan 07 09:37:26 CET 2014]; parent: Root WebApplicationContext
  09:37:26,926 INFO  [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (MSC service thread 1-10) Registering annotated classes: [class com.myproject.configuration.WebMvcConfig]
  09:37:26,973 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-10) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
  09:37:27,041 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC service thread 1-10) Mapped "{[/ || /welcome],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.myproject.controller.BaseController.welcome(org.springframework.ui.ModelMap,java.lang.String)
  09:37:27,043 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC service thread 1-10) Mapped "{[/bindcheck/{dn}/{pwd}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.myproject.controller.BaseController.canUserBind(java.lang.String,java.lang.String,org.springframework.ui.ModelMap)
  09:37:27,045 INFO  [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (MSC service thread 1-10) Mapped "{[/usersearch/{userId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.myproject.controller.BaseController.usersearch(java.lang.String,org.springframework.ui.ModelMap)
  09:37:27,066 INFO  [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (MSC service thread 1-10) Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
  09:37:27,149 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-10) Hibernate Validator 4.2.0.Final
  09:37:27,231 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-10) FrameworkServlet 'dispatcher': initialization completed in 312 ms
  09:37:27,238 INFO  [org.jboss.web] (MSC service thread 1-10) JBAS018210: Registering web context: /my-project
  09:37:27,243 INFO  [org.jboss.as] (MSC service thread 1-13) JBAS015951: Admin console listening on http://127.0.0.1:9990
  09:37:27,243 INFO  [org.jboss.as] (MSC service thread 1-13) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 5294ms - Started 226 of 303 services (76 services are passive or on-demand)
  09:37:27,279 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "my-project.war"
  09:37:33,221 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) null
  </code></pre>