springboot中css js等靜態資源被攔截

2021-10-08 18:49:14 字數 574 閱讀 6422

springboot 2.3的版本***會攔截靜態資源。使用***時需新增excludepathpatterns讓所需靜態資源放行

我們自己的css、js等靜態資源放在resources / static / asserts下

而從pom檔案裡面引入的jquery、bootstrap放在了webjars下

所以控制靜態資源放行時"/asserts/**","/webjars/**都要加上

registry.addinterceptor(new loginhandlerinterceptor()).addpathpatterns("/**")

.excludepathpatterns("/index.html","/","/user/login","/asserts/**","/webjars/**");

SpringBoot靜態資源失效css js失效

我這裡是因為 解決配置 後,靜態資源失效問題。一種情況,兩種方法!這裡直接上 configuration public class interceptorconfig extends webmvcconfigurationsupport override protected void addreso...

Springboot中Thymeleaf外部模板

spingboot專案中,預設的thymeleaf模板資料夾是在 src main resources templates,打包時後在classpath templates下 jar包同目錄下的 templates 目錄 spring.thymeleaf.prefix file templates ...

springboot中controller無法訪問

configuration 該註解將類可以看成配置檔案,通常和 bean配合使用 enableautoconfiguration 在程式啟動時自動載入配置 componentscan 會自動掃瞄指定包下的全部標有 component的類,並註冊成bean,當然包括 component下的子註解 se...