SpringBoot访问本地静态资源

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cxfly957/article/details/84831820

需要在application.properties文件里配置如下配置项:

#配置本地资源路径,必须以/结尾
filePath=E:/file/
#配置静态资源拦截方式和静态资源路径
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:${filePath}

比如,E:/file/ 路径下有一个 test.jpg的图片,访问该图片的地址即为:http://ip:port/test.jpg

猜你喜欢

转载自blog.csdn.net/cxfly957/article/details/84831820