如图,我用Springboot+thymeleaf 返回了页面,但访问静态资源有问题。类型也不对。我有整合了Shiro框架
shiro过滤部分:
资源目录:
页面引用css:
<link href="/dist/css/style.min.css" rel="stylesheet">
用这个标签时会报错:
<link th:href="@{/static/dist/css/style.min.css}" rel="stylesheet" type="text/css"/>
No mapping for GET /auth/static/dist/css/style.min.css
yml配置:
spring:
mvc:
static-path-pattern: /static/**
view:
prefix: /templates/
suffix: .html
resources:
static-locations: classpath:/static/
thymeleaf:
#缓冲的配置
cache: false
check-template: true
check-template-location: true
#开启MVC thymeleaf 视图解析
enabled: true
encoding: utf-8
mode: HTML
prefix: classpath:/templates/
suffix: .html
https://www.cnblogs.com/kingsonfu/p/11516967.html
你的spring boot版本多少?如果是2.x的,还需要在拦截器中取消dist开头的文件拦截。
建议配置改为:static-path-pattern: /**
然后访问路径前面不要带static。filter..那里不要配anon等,如果怕被拦截就在拦截器里过滤,参考链接spring boot2.x访问静态资源
<link href="/dist/css/style.min.css" rel="stylesheet">应该是对的。
如果想用th标签建议改为
<link th:href="@{/dist/css/style.min.css}" rel="stylesheet" type="text/css"/>
总之你的url路径不要带static。