Rectangle 27 1

java Annotation Configuration Replacement for mvc:resources Spring?


@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}

@Menuka Explaination: Every request which begins with "/resources/**" path will be mapped to a files in a "/resources/" folder.

One way to do this is to have your configuration class extend WebMvcConfigurerAdapter, then override the following method as such:

This answer is totally correct. However, if you're having issues (like I was) after adding this, remember that you might still need a default servlet handler described here: stackoverflow.com/a/17013442/2047962

Upvoted for the answer. Better if you can add explanation. That would be nice for a beginner.

Note