5

In spring the resource handler is working fine

 <mvc:resources mapping="/Lab/**" location="/WEB-INF/Assets/Lab/"/>
 <mvc:resources mapping="/Tools/**" location="/WEB-INF/Assets/Tools/"/>
 <mvc:resources mapping="/Images/**" location="/WEB-INF/Assets/Images/"/>

How can i add multiple resources in spring boot?

The below code is not working

@Configuration
@EnableWebMvc
public class ResourceHandlers extends WebMvcConfigurerAdapter 
{
    @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) 
        {
            registry
            .addResourceHandler("/Lab/**")
            .addResourceLocations("/WEB-INF/Assets/Lab/"); 

            registry
            .addResourceHandler("/Tools/**")
            .addResourceLocations("/WEB-INF/Assets/Tools/");

            registry
            .addResourceHandler("/Images/**")
            .addResourceLocations("/WEB-INF/Assets/Images/");
        }
}
Pamba
  • 776
  • 1
  • 16
  • 29

1 Answers1

9
 registry
    .addResourceHandler("/Lab/**", "/Tools/**", "/Images/**")
    .addResourceLocations("/WEB-INF/Assets/Lab/", 
"/WEB-INF/Assets/Tools/", 
"/WEB-INF/Assets/Images/");

It allows multiple arguments

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • But when i enable 'addResourceHandlers' an error occured while accessing index page 'Could not resolve view with name Index' in servlet with name 'dispatcherServlet''. After commenting the class 'ResourceHandlers ' it will work. Any idea? – Pamba Apr 28 '17 at 09:29
  • No idea. I would say it's a different question and you need to provide more details - where your resources located, what is called etc. http://stackoverflow.com/questions/25061237/spring-4-addresourcehandlers-not-resolving-the-static-resources – StanislavL Apr 28 '17 at 09:32