SEC7113: CSS was ignored due to mime type mismatch

匿名 (未验证) 提交于 2019-12-03 02:03:01

问题:

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

               <span class="typ" bdsfid="201">Test</span>                        ............... 

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?

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!