How to configure the mvc resoures tag without xml

0

Good evening.

I'm trying to set up the annotation of xml without, as per the code below, to add my js / css pages inside, but I'm not getting it.

public class AppWebConfiguration {

@Bean
public InternalResourceViewResolver internalResourceViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/views/");
    resolver.setSuffix(".jsp");
    // <mvc:resources mapping ="/resources/** location="/resources/"/>
    return resolver;
}

}

Thank you.

    
asked by anonymous 29.03.2017 / 03:50

1 answer

0
    // equivalents for <mvc:resources/> tags
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/css/**").addResourceLocations("/css/").setCachePeriod(31556926);
        registry.addResourceHandler("/img/**").addResourceLocations("/img/").setCachePeriod(31556926);
        registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(31556926);
    }

For more details, see this answer.

link

    
29.03.2017 / 18:41