Spring MVC - ResourceHandlerRegistry Examples

Code Snippets Spring MVC 

@SpringBootApplication
public class Main {

public static void main (String[] args) {
SpringApplication.run(Main.class, args);
}

@Bean
public WebMvcConfigurerAdapter webConfigurer () {
return new WebMvcConfigurerAdapter() {
@Override
public void addResourceHandlers (ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**")
.addResourceLocations("/static/")
.setCachePeriod(30);
}
};
}
}
Original Post




    @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//specifying static resource location for themes related files(css etc)
registry.addResourceHandler("/themes/**")
.addResourceLocations("/app-themes/");
}
Original Post




See Also