Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

html - SEC7113: CSS was ignored due to mime type mismatch

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

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

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>

How do I solve this issue?

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.

I can see that Type is not coming as text/css. But Why? enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Ok,

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);
    }

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...