springboot中怎么实现默认静态路径
更新:HHH   时间:2023-1-8


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中怎么实现默认静态路径的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注天达云行业资讯频道,感谢各位的阅读!

返回编程语言教程...