美文网首页
SpringBoot找不到静态资源文件

SpringBoot找不到静态资源文件

作者: zqyadam | 来源:发表于2022-01-11 09:09 被阅读0次

问题

放在resources/static下的静态css、js文件无法访问,报404错误

解决方法:

application.properties文件中,增加

# 静态路径pattern
spring.mvc.static-path-pattern=/**

然后就可以在templates/index.html文件中按以下方式访问了

    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>

相关文章

网友评论

      本文标题:SpringBoot找不到静态资源文件

      本文链接:https://www.haomeiwen.com/subject/zikbcrtx.html