Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i add multiple resource handler in spring boot

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/");
        }
}
like image 893
Pamba Avatar asked Feb 04 '23 13:02

Pamba


1 Answers

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

It allows multiple arguments

like image 62
StanislavL Avatar answered Feb 07 '23 17:02

StanislavL