The effect is that our pictures are in the computer d Under the plate . I want to use it localhost:8080/files/img.jpg Visit that picture .
First add the following to the project java file
@Component class WebConfigurer extends WebMvcConfigurerAdapter { @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// to configure server Virtual path ,handler by jsp Directory accessed in ,locations by files Corresponding local path
registry.addResourceHandler("/files/**").addResourceLocations(" The local disk path is as follows :file:///D:/filesdir/");
} }
This way, when we use <img src="${ctx}/files/img.jpg"/> You can see the picture (${ctx} amount to localhost:8080)