springboot中如何实现默认静态路径
更新:HHH   时间:2023-1-7


这篇“springboot中如何实现默认静态路径”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“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文件夹

以上就是关于“springboot中如何实现默认静态路径”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注天达云行业资讯频道。

返回移动开发教程...