- 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
轉載于:https://www.cnblogs.com/LJing21/p/11477821.html