以编程方式禁用在Intranet中运行的站点的IE-8兼容模式并呈现.xhtml页面 [英] To programmatically disable IE-8 compatibility mode for the site running in intranet and rendering .xhtml pages
本文介绍了以编程方式禁用在Intranet中运行的站点的IE-8兼容模式并呈现.xhtml页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSF应用程序,在intranet中运行.xhtml页面。我尝试删除默认元标记并添加元标记
I have a JSF application with .xhtml pages running in intranet.I tried removing default meta tag and add the meta tag
<meta http-equiv="X-UA-Compatible" content="IE=8" />
但是没有用。这个解决方案只适用于普通的html页面,还是有其他方式使用我可以通过编程方式禁用兼容模式。
But there is no use.Is this solution only for plain html pages or is there any other way using which i can programmatically disable compatibility mode.
推荐答案
如果你想阻止所有JSF页面的兼容性模式你
If you want to prevent the compatibility mode for all your JSF pages you better use a filter for this:
Java
public class NoCompatibilityMode implements Filter {
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
ServletException {
if (((HttpServletRequest) req).getRequestURI().endsWith(".js.jsf")
|| ((HttpServletRequest) req).getRequestURI().endsWith(".css.jsf")) {
chain.doFilter(req, res);
} else {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("X-UA-Compatible", "IE=edge"); // No more Compatibility Mode
chain.doFilter(req, res);
}
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
web.xml
<filter>
<filter-name>NoCompatibilityMode</filter-name>
<filter-class>my.package.name.NoCompatibilityMode</filter-class>
</filter>
<filter-mapping>
<filter-name>NoCompatibilityMode</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
这篇关于以编程方式禁用在Intranet中运行的站点的IE-8兼容模式并呈现.xhtml页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文