How to configure the mvc resoures tag without xml

Asked

Viewed 18 times

0

Good night.

I’m trying to configure the annotation of xml without, according to 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.

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.

https://stackoverflow.com/a/17013442/3137441

Browser other questions tagged

You are not signed in. Login or sign up in order to post.