title: Spring 4 - addResourceHandlers not resolving the static resources
body: <p>My maven spring project directory structure is shown below. I am using Spring-4 annotation based configuration. I configure the resources like below. I tried many ways that are suggested in many Stackoverflow questions and other websites </p>
  
  <p><a href="https://stackoverflow.com/questions/24080025/spring-4-loading-static-resources">Spring 4 loading static resources</a></p>
  
  <p><a href="http://imwill.com/spring-mvc-4-add-static-resources-by-annotation/#.U5GZlXKs9i4" rel="noreferrer">http://imwill.com/spring-mvc-4-add-static-resources-by-annotation/#.U5GZlXKs9i4</a></p>
  
  <p>But the jsp files could not load the resources, all the static content requests returns 404 error. I tried these things in jsp, </p>
  
  <pre><code> &lt;link href="resources/css/bootstrap.css" rel="stylesheet" media="screen"&gt;
   &lt;link href="/resources/css/bootstrap.css" rel="stylesheet" media="screen"&gt;
   &lt;link href="css/bootstrap.css" rel="stylesheet" media="screen"&gt;
  </code></pre>
  
  <p>EDIT: I am using servlet 2.5 because as of now I cannot upgrade my project from JBoss 5 to higher versions. JBoss5 do not support servlets 3, and do that matter?</p>
  
  <pre><code>@Configuration
  @ComponentScan("com.mgage.mvoice")
  public class MyAppWebConfig extends WebMvcConfigurerAdapter {
       public void addResourceHandlers(ResourceHandlerRegistry registry) {  
          // I tried these many combinations separately.
  
          ResourceHandlerRegistration resourceRegistration = registry
              .addResourceHandler("resources/**");
          resourceRegistration.addResourceLocations("/resources/**");
          registry.addResourceHandler("/css/**").addResourceLocations("/css/**");
          registry.addResourceHandler("/img/**").addResourceLocations("/img/**");
          registry.addResourceHandler("/js/**").addResourceLocations("/js/**");
          registry.addResourceHandler("/resources/**")
                  .addResourceLocations("classpath:/resources/"); 
                // do the classpath works with the directory under webapp?
       }
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/IV6iP.png" alt="Project structure"></p>