<meta http-equiv=“X-UA-Compatible” content=“IE=8” /> ignored in RichFaces webapp

自作多情 提交于 2019-12-04 11:27:28
BalusC

From IE developer documentation, Defining Document Compatibility:

...

The X-UA-Compatible header is not case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.

...

RichFaces 3.3.3 by default auto-includes <link> elements referring RichFaces-specific CSS stylesheets in very top of the head, before the original <head> template content. So the X-UA-Compatible header in flavor of a HTML <meta> element would always fail to work in a RichFaces 3.3.3 webapp. That it works fine in your local development environment is most likely because you've added the localhost site to the list of IE8 compatible sites in browser configuration. The presence of the X-UA-Compatible header doesn't matter anymore then.

Your best bet is to set the X-UA-Compatible header directly on the HTTP response itself instead of as a HTML meta tag. You can do that with a simple servlet filter which is mapped on FacesServlet and does the following job:

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    ((HttpServletResponse) response).setHeader("X-UA-Compatible", "IE=8");
    chain.doFilter(request, response);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!