Spring Boot 菜鸟教程 25 静态资源路径

GitHub

src="//ghbtns.com/github-btn.html?user=je-ge&repo=spring-boot&type=watch&count=true" scrolling="0" width="110" height="20">

静态资源路径

是Spring Boot系统直接就可以访问的路径,且路径下的所有文件均可直接读取。

默认的静态资源路径有

在哪个配置文件里面定义的?
静态资源路径都是在classpath中

classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
源码定义
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {  
        "classpath:/META-INF/resources/", "classpath:/resources/",  
        "classpath:/static/", "classpath:/public/" };  

覆盖默认的静态资源路径

可以使用application.properties配置文件覆盖静态资源路径

#这个属于自定义的属性,指定了一个路径,注意要以/结尾
je-ge-webUploadPath=D:/JE-GE/SpringBoot/
#表示所有的访问都经过静态资源路径
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,\
  classpath:/static/,classpath:/public/,file:${je-ge-webUploadPath}

其他关联项目

源码地址

https://github.com/je-ge/spring-boot

如果觉得我的文章或者代码对您有帮助,可以请我喝杯咖啡。
您的支持将鼓励我继续创作!谢谢!
微信打赏
支付宝打赏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值