類別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中如何實現預設靜態路徑的詳細內容。更多資訊請關注PHP中文網其他相關文章!