springboot 默认静态路径实例解析

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

springboot 默认静态路径实例解析

  2021-04-02 我要评论

这篇文章主要介绍了springboot 默认静态路径实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

代码如下所示

类ResourceProperties.class

private static final String[] CLASSPATH_RESOURCE_LOCATIONS = new String[]{"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"};
private String[] staticLocations;

public ResourceProperties() {
 this.staticLocations = CLASSPATH_RESOURCE_LOCATIONS;
 this.addMappings = true;
 this.chain = new ResourceProperties.Chain();
 this.cache = new ResourceProperties.Cache();
}

根据构造方法可知, staticLocations等于默认的CLASSPATH_RESOURCE_LOCATIONS, 也即"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/"

classpath即为我们如下图所示的resource文件夹

您可能感兴趣的文章:

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们