SpringBoot - 静态资源访问

1.在springboot项目种默认访问静态资源是在resources(classpath:/)下的这四个文件夹顺序为:

META-INF/resources > resources > static > public

 

2.设置视图解析器前缀与后缀

spring:
  mvc:
    view:
      #1.设置视图解析器前后缀
      prefix: html/
      suffix: .html
      #2.默认为/**  /*.html 就能访问到静态资源
      #修改为/admin/**时 必须加/admin/*.html 才能访问到静态资源
      static-path-pattern: /admin/**

 

3.修改默认静态资源访问路径

spring:
    resources:
      static-locations: [classpath:public/,file:C:\test]

 

posted on 2021-12-11 21:56  每天积极向上  阅读(164)  评论(0编辑  收藏  举报

导航