1. 程式人生 > >訪問路徑對映到本地

訪問路徑對映到本地

import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration @EnableWebMvc @Component public class StaticFile extends WebMvcConfigurerAdapter {     @Value("${pictureStorePath}")//    "D:/staticFile/pic/"     private String pictureStorePath;          @Value("${pictureReadPath}")// "/videoshot/pic/"     private String pictureReadPath;          @Value("${excelSotrPath}")// "D:/staticFile/excel/"     private String excelSotrPath;          @Value("${excelReadPath}")//  "/videoshot/excel/"     private String excelReadPath;                   @Override         public void addResourceHandlers(ResourceHandlerRegistry registry) {             registry.addResourceHandler(pictureReadPath+"/**").addResourceLocations("file:"+pictureStorePath+"/");             registry.addResourceHandler(excelReadPath+"/**").addResourceLocations("file:"+excelSotrPath+"/");             super.addResourceHandlers(registry);         } }