spring boot, 好處:快速開發微服務,使每一個服務負責本身的功能,單獨模塊更新重啓互不影響;javascript
目錄結構: resources:css
static:靜態資源(js css img 音頻 視頻)html
templates:模板文件(thymeleaf,默認不支持jsp)java
application.properties:配置文件jquery
web程序: web
web靜態資源路徑指定:WebMvcAutoConfiguration addResourceHandlers 指定/webjars/spring
webjars:將靜態資源以jar文件 maven的形式加入maven,從jar包目錄結構的webjars開始app
https://www.webjars.org/ 好比jquery:jsp
<dependency> <groupId>org.webjars</groupId> <artifactId>jquery</artifactId> <version>3.3.1-2</version> </dependency>
http://localhost:8080/webjars/jquery/3.3.1-2/jquery.jsmaven
spring 默認靜態資源存放路徑:
public class ResourceProperties { private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/" };
訪問以上目錄資源時,不須要添加前綴;
自定義U靜態資源目錄:
application.resources:
spring.resources.static-locations=classpath:/res/
使用自定義靜態資源目錄之後,默認路徑失效;
默認歡迎頁面位置:
private Resource getIndexHtml(String location) { return this.resourceLoader.getResource(location + "index.html"); }
網站logo默認icon位置:任意靜態資源目錄:**/favicon.ico