我有一个JSF应用程序,在intranet中运行.xhtml页面。我尝试删除默认元标记并添加元标记
<meta http-equiv="X-UA-Compatible" content="IE=8" />
但是没有用。这个解决方案只适用于普通的html页面,或者是否有任何其他方法可以用来编程禁用兼容模式。
答案 0 :(得分:2)
如果您想阻止所有JSF页面的兼容性模式,更好使用过滤器:
<强>爪哇强>
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>