【问题标题】:Resource interpreted as Stylesheet but transferred with MIME type text/html error in console资源解释为样式表,但在控制台中传输 MIME 类型文本/html 错误
【发布时间】:2014-11-06 01:41:49
【问题描述】:

我试图在我的 Angular 应用程序中包含 flexslider,但在包含 flexslider css 文件后出现以下错误

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/controlpanel/users/css/style.css". 

我检查了我的文件位置是否不正确,但它是正确的

【问题讨论】:

    标签: html css mime-types


    【解决方案1】:

    您的网络服务器未在 HTTP 标头中使用正确的 Content-Type 提供资源。您的网络服务器应该有一个文件扩展名的 MIME 类型设置,但这取决于您使用的服务器。

    【讨论】:

      【解决方案2】:

      我也遇到过同样的问题。好吧,我只是想用一个 servlet 来加载欢迎 jsp 页面,该页面在 header 中包含一个 .css 文件。

      <head>
         <link rel="stylesheet" type="text/css" href="css/base.css">
      </head>
      

      我得到了同样的错误“资源解释为样式表但使用 MIME 类型 text/html 传输:“http://localhost:8080/webapp/css/style.css

      当我在 chrome 中使用开发人员工具时,在“网络”选项卡下,当点击我的 web 应用程序的登陆网址“http://localhost:8080/webapp/”时,会进行两次调用

      我在 web.xml 中将我的默认 servlet url 从“/”更改为“/index”

      <servlet-mapping>
          <servlet-name>NextServlet</servlet-name>
          <url-pattern>/index</url-pattern>
      </servlet-mapping>
      

      然后将“./”添加到href,

       <head>
         <link rel="stylesheet" type="text/css" href="./css/base.css">
      </head>
      

      成功了。

      【讨论】:

        猜你喜欢
        • 2018-08-16
        • 2012-09-20
        • 2012-05-20
        • 1970-01-01
        • 2014-11-19
        • 2013-05-04
        • 2011-12-13
        • 2017-10-12
        • 2016-03-19
        相关资源
        最近更新 更多