Issue
my code like this, ues a static resource mapping
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/scene/template/{id}/file/**").addResourceLocations("file:" +"upload/**");
}
i want to use http://localhost:8890/scene/template/1/file/frame.js to visit the file
how can i do it?
Solution
Is it something like this?
@Configuration
@EnableWebMvc
public class ResourceConfigs implements WebMvcConfigurer {
private static final String[] CLASS_PATH_RESOURCE_LOCATIONS = {
"file:///home/akhil/Downloads/scene/template/"
};
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/scene/template/**")
.addResourceLocations(CLASS_PATH_RESOURCE_LOCATIONS)
.setCacheControl(CacheControl.noCache().cachePrivate())
.resourceChain(true)
.addResolver(new PathResourceResolver());
}
}
This worked for me.
Answered By - Akhil
Answer Checked By - Mary Flores (JavaFixing Volunteer)