【问题标题】:Using webjar and spring mvc, fonts in the css are not loaded使用webjar和spring mvc,css中的字体没有加载
【发布时间】:2015-07-15 20:10:09
【问题描述】:

对于一个全新的网站,我使用的是 Spring MVC 和 the materialize webjar :) 它工作得很好,期待字体:(它们没有加载!

  1. 在 Spring MVC 应用程序中,http://localhost/website/test 可以访问以下方法

  2. 当我加载这个页面时,我看到字体没有加载:(它应该是一个图标而不是 send)。

  3. Materilize css 文件通过 jsp 页面中的以下导入加载:http://localhost:8180/webjars/materialize/0.97.0/bin/materialize.css

  4. 所以我认为没有加载字体是因为materialize.css 中的链接不是基于根的:src: url("../font/material-design-icons/Material-Design-Icons.eot?#iefix")。我猜,应用程序尝试在此处加载文件:http://localhost/website/font/material-design-icons/Material-Design-Icons.eot?#iefix 而它应该在此处加载文件:http://localhost/webjars/materialize/0.97.0/font/material-design-icons/Material-Design-Icons.ttf(当我手动测试时它正在工作)

我在 Chrome 的“网络”选项卡中看不到任何 404 错误。所以我不知道应用程序是否会尝试加载字体。

我找到了一个修复方法,即在 head 标签中添加以下行:<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">。在这种情况下它可以工作......

我不明白为什么 webjar 没有加载字体...你有什么想法吗?

【问题讨论】:

    标签: spring-mvc fonts webjars


    【解决方案1】:

    也许尝试从 dist 目录加载 css:

    http://localhost:8180/webjars/materialize/0.97.0/dist/css/materialize.css
    

    【讨论】:

    • 您是否在网络调试器中看到了对字体的 Web 请求?
    猜你喜欢
    • 2021-11-01
    • 1970-01-01
    • 2017-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-30
    • 2016-05-16
    • 1970-01-01
    相关资源
    最近更新 更多