I am developing a webapp using Spring MVC 3 and have the DispatcherServlet
catching all requests to \'/\' like so (web.xml):
For java based spring configuration you can use the following
Using ResourceHandlerRegistry which stores registrations of resource handlers for serving static resources.
More Info @ WebMvcConfigurerAdapter which defines callback methods to customize the Java-based configuration for Spring MVC enabled via @EnableWebMvc.
@EnableWebMvc
@Configurable
@ComponentScan("package.to.scan")
public class WebConfigurer extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static_resource_path/*.jpg").addResourceLocations("server_destination_path");
}