1

Every time I want to use ResourceHandlerRegistry.addResourceHandler(..) to tell Spring a certain directory is resource, I need to specify a path for the handler and a path for resource location, for instance.

registry.addResourceHandler("/javascript/**").addResourceLocations("/javascript/");
registry.addResourceHandler("/html/**").addResourceLocations("/html/");

This gets very repetitive when I have more than one resource directory. Is it possible to tell Spring MVC, "/html" or "/javascript" are resource directories?

Hong Z.
  • 45
  • 4

2 Answers2

0

Every directory is a directory in spring. To exclusively specify resource folder you have to have this configuration. Otherwise for all resource requests spring will start finding out controller mapping.

Ankur Gupta
  • 301
  • 4
  • 12
0

Found the answer from this other StackOverflow question https://stackoverflow.com/a/31349904/1772825

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    configurer.enable();
}
Community
  • 1
  • 1
Hong Z.
  • 45
  • 4