< meta http-equiv =“与X-UA兼容"; content ="IE = 8" />在RichFaces Webapp中被忽略 [英] <meta http-equiv="X-UA-Compatible" content="IE=8" /> ignored in RichFaces webapp

查看:122
本文介绍了< meta http-equiv =“与X-UA兼容"; content ="IE = 8" />在RichFaces Webapp中被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Glassfish 2.1上使用JSF 2.0和RichFaces 3.3.3.我创建了一个带有模式面板的Web应用程序,该模式在我的计算机(本地服务器)上运行良好.由于特定RichFaces版本的IE9不兼容,我在HTML头中使用了X-UA-Compatible: IE=8元标记:

I'm using JSF 2.0 and RichFaces 3.3.3 on Glassfish 2.1. I've created a web application with a modal panel that works great in my computer (local server). Because of IE9 incompatibility of the specific RichFaces version, I'm using the X-UA-Compatible: IE=8 meta tag in my HTML head:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

当我在本地环境中部署时,模式面板如下所示:

The modal panel look like this when I deploy in my local environment:

但是当我在生产服务器中进行部署时,我遇到了问题.

But when I deploy in the production server, I've a problem.

如果我将IE与兼容视图一起使用
(来源: geneanet.org )
,我的模式面板如下所示:

If I use IE with compatibility view
(source: geneanet.org)
, my modal panel look like this:

如果我不使用兼容性视图,则会看到模式面板,但是我所有的ajax按钮都无法正常工作.

If I don't use the compatibility view, I see the modal panel but all my ajax buttons don't work.

这是怎么引起的,我该如何解决?

How is this caused and how can I solve it?

推荐答案

从IE开发人员文档中,

From IE developer documentation, Defining Document Compatibility:

...

...

X-UA-Compatible标头不区分大小写;但是,它必须出现在网页标题(HEAD部分)中除title元素和其他元元素之外的所有其他元素之前.

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默认情况下会在头部的非常顶部(在之前原始<head>模板中)自动包含<link>元素,这些元素引用RichFaces特定的CSS样式表内容.因此,具有HTML <meta>元素风格的X-UA-Compatible标头将始终在RichFaces 3.3.3 Web应用程序中始终无法工作.它很可能在您的本地开发环境中运行良好,这很可能是因为您已将本地站点添加到浏览器配置中的IE8兼容站点列表中. X-UA-Compatible标头的存在不再重要.

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.

您最好的选择是直接在HTTP响应本身上设置X-UA-Compatible标头,而不是将其设置为HTML元标记.您可以使用一个简单的 servlet过滤器来做到这一点,该过滤器映射到FacesServlet上并完成以下工作:

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

这篇关于&lt; meta http-equiv =“与X-UA兼容"; content ="IE = 8" /&gt;在RichFaces Webapp中被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆