Use the spring mvc support for static resources, its location
attribute is an Spring Resource
, so you could use file:
prefix
<resources mapping="/resources/**" location="file:/my/external/directory/" />
or
@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("file:/my/external/directory/");
}
}
@See Spring Reference Chapter 6.4 The ResourceLoader for a table that list all prefixed for resources
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…