配置静态目录,一共两个属性
配置请求规则
spring.mvc.static-path-pattern=/**
ex:
spring.mvc.static-path-pattern=/abc/**
也就是说 url请求地址为/abc/开头的 才会被处理
配置静态目录
默认情况下:
spring.resources.static-locations=classpath:/static,classpath:/public,classpath:/resources,classpath:/META-INF/resources
我们可以根据需求来自己定义
spring.resources.static-locations=classpath:/static/img/,classpath:/static/css/

如果springboot是jar包运行的时候,我们需要把资源放到其他目录下。
所以我们可以这样:
web.upload-path=c:/jsr_img/
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,\
classpath:/static/,classpath:/public/,file:${web.upload-path}
网友评论