spring:
  mvc:
#   “spring.mvc.static-path-pattern”用于阐述HTTP请求地址,请求非controller地址,如js,css,img等访问路径需要加上static,
# 可以不配置也能访问图片
#  而“spring.resources.static-locations”则用于描述静态资源的存放位置。多个路径(逗号隔开)中依次查找是否存在
    static-path-pattern: /static/**
  resources:
    static-locations: classpath:/static/,file:D:\\

 


下面是一个访问本地图片的例子:

yml配置之static-path-pattern 与 static-locations,静态资源的访问

方框1:url中访问路径,这里为:localhost:8080/static/...

方框2:本地图片保存的路径,image会根据d:\\和浏览器中输入的图片名字自动查找图片

 

  yml配置之static-path-pattern 与 static-locations,静态资源的访问

 

 yml配置之static-path-pattern 与 static-locations,静态资源的访问

还有一种 访问本地服务器上的tomcat 映射方法:

<Context path="/user_images" docBase="C:\assets\file\user_images"  reloadable="true"></Context> 

 

相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2021-06-26
  • 2021-11-24
  • 2022-12-23
  • 2021-07-25
  • 2022-01-02
  • 2021-11-30
猜你喜欢
  • 2022-12-23
  • 2021-12-10
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
相关资源
相似解决方案