The effect is that, for example, our pictures are in the computerd Under the tray. I want to use it.localhost:8080/files/img.jpg Visit that picture.
First add the following to the projectjava file
@Component class WebConfigurer extends WebMvcConfigurerAdapter { @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// To configureserver Virtual path,handler byjsp Directories accessed in,locations byfiles Corresponding local path
registry.addResourceHandler("/files/**").addResourceLocations(" The local disk path is as follows:file:///D:/filesdir/");
} }
So when we use<img src="${ctx}/files/img.jpg"/> You can see the picture by(${ctx} Amount tolocalhost:8080)