Domanda

I just converted an XML configured Spring MVC project to being annotation based but I cannot seem to figure out what annotation to use (and where to place it) for static resource mappings. The mappings in my project's older XML based configuration were:

<mvc:resources mapping = "/css/**" location = "/css/"/> <mvc:resources mapping = "/images/**" location = "/images/"/> <mvc:resources mapping = "/*.html" location = "/"/>

Any help appreciated.

È stato utile?

Soluzione

@Configuration  
@EnableWebMvc  
public class WebAppConfig extends WebMvcConfigurerAdapter {  

        @Override  
        public void addResourceHandlers(ResourceHandlerRegistry registry) {  
                registry.addResourceHandler("/css/**").addResourceLocations("/css/");  
        }  
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top