springBoot configure url to access pictures

l Configuration:

@Configuration
 public  class WebMvcConfigurer the extends WebMvcConfigurerAdapter { 

    @Override 
    public  void addResourceHandlers (ResourceHandlerRegistry Registry) {
         // and related static pages directories are placed under static directory project 
        registry.addResourceHandler ( "/ static / **" ). AddResourceLocations ( " the CLASSPATH: / static / " );
         // uploaded images in the OTA directory of the D drive, such as access path: HTTP: // localhost : 8080 / XXX.jpg 
    } 

}

Schematic:

 

Normal browser visit:

 

 

Guess you like

Origin www.cnblogs.com/nongzihong/p/10967356.html