由于MIME类型不匹配

由于MIME类型不匹配

本文介绍了SEC7113:由于MIME类型不匹配,CSS被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Jsp-Servlet应用程序。
我使用Eclipse和Default Tomcat 7部署了应用程序。

I am developing a Jsp-Servlet application.I deployed the application using Eclipse with Default Tomcat 7.

然而,在部署应用程序之后,在Chrome / Firefox中,
其中IE10或更高版本在控制台中显示此警告,并且未加载任何UI元素。

However after deploying the application, in Chrome/Firefox the UI gets rendered properly.Where as in IE10 or later is showing this warning in console and none of the UI elements are loaded.

SEC7113: CSS was ignored due to mime type mismatch

这是css文件的引用方式

This is how the css files are referred

<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
        <link rel="shortcut icon" href="images/rpt.ico" type="image/x-icon">
        <link href="css/custom.css" rel="stylesheet" type="text/css" />
    </head>
...............
</html>

如何解决此问题?

更新如果我以兼容模式运行网站,它的呈现很好。但是我应该如何使它工作,即使它没有启用。

Update If I run the site in Compatible mode, it's rendering fine. But how should I make it work even if it's not enabled.

我可以看到类型不是作为文本/ CSS。但为什么?
>

推荐答案

好的,

我发现没有办法从服务器端[tomcat] web.xml。
然后我找到一个解决方法使用过滤器实现

I found that there's no way of doing from server side [tomcat] and tried with web.xml too.Then I found a workaround using a Filter Implementation

   @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        if(request.getHeader("accept")!=null && request.getHeader("accept").contains("css")){
            response.setHeader("Content-Type", "text/css");
        }
        chain.doFilter(req, response);
    }

我明确设置了 text / css 用于css请求。然后它工作正常。

I explicitly set text/css for css requests. Then it's working fine.

这篇关于SEC7113:由于MIME类型不匹配,CSS被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 05:20