【问题标题】:Spring boot: Unable to resolve static contentSpring Boot:无法解析静态内容
【发布时间】:2015-12-09 07:38:50
【问题描述】:

如何使用 spring-boot 解析静态内容路径?应用程序无法找到以下 css。我需要实现 addResourceHandlers 方法吗?还是 spring-boot 提供了简单的配置?

<link rel="stylesheet" href="../static/css/sghome.css" />

【问题讨论】:

    标签: spring spring-boot


    【解决方案1】:

    无需使用相对路径。请改用以下内容:

    <link rel="stylesheet" href="css/sghome.css" />
    

    【讨论】:

    • 确实,Spring 将 static/(或 public/)和 templates/ 都映射到根目录。两者的主要区别在于 templates/ 用于动态模板(thymeleaf,velocity,...),另一个用于静态资源(CSS,JS,images,...),但您可以将它们用作如果它们在同一个文件夹中。
    • @g00glen00b 感谢您的解释。
    猜你喜欢
    • 2018-02-10
    • 2017-11-06
    • 1970-01-01
    • 2017-12-05
    • 2018-06-26
    • 2022-01-02
    • 1970-01-01
    • 2017-07-19
    • 2017-04-05
    相关资源
    最近更新 更多