- springboot整合了springmvc的攔截功能。攔截了所有的請求。默認放行的資源是:resources/static/ 目錄下所有靜態資源。(不走controller控制器就能直接訪問到資源)。
-
html頁面如果放在resources/templates目錄下,則需要走controller控制器,controller放行,允許該資源訪問,該資源才能被訪問到。否則就會報404錯誤(它不可以直接被訪問)。
-
- springboot項目中templates包下的html代碼無法引入static下的靜態文件。
- 在 .properties中添加:spring.mvc.static-path-pattern=/static/**
- 關於springboot中thymeleaf的配置:
spring.mvc.static-path-pattern=/static/** spring.thymeleaf.servlet.content-type=text/html spring.thymeleaf.mode=HTML spring.thymeleaf.cache=false spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html