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}
其他关联项目
- Spring Boot 菜鸟教程 13 注解定时任务
http://blog.csdn.net/je_ge/article/details/53434227 - Spring Boot 菜鸟教程 7 EasyUI-datagrid
http://blog.csdn.net/je_ge/article/details/53365189
源码地址
https://github.com/je-ge/spring-boot
如果觉得我的文章或者代码对您有帮助,可以请我喝杯咖啡。
您的支持将鼓励我继续创作!谢谢!