IE10 浏览器 - X-UA 兼容 " content=" IE=8 不起作用



我的应用程序在IE8中运行良好,当涉及到IE10时,它只在可计算性视图和IE8标准中运行良好。为了强制浏览器以相同的模式工作,我在jsp 中使用了以下代码

<!DOCTYPE HTML>
<html>
  --any code
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=8">
  </head>
  --any code
</html>

但IE10一直使用IE7标准。上面的代码有什么错误吗?请提出建议。

我让它通过servelet过滤器工作,它将始终确保在相同的模式下工作。

 public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
    if (compatibilityMode != null) {
        HttpServletResponse res = (HttpServletResponse) resp;
        res.addHeader("X-UA-Compatible", compatibilityMode);
    }
    chain.doFilter(req, resp);
}
public void init(FilterConfig config) throws ServletException {
  String compatibilityMode = config.getInitParameter("compatibilityMode");
}

使用以下通过web.xml设置可计算性模式

<filter>
    ....
    <init-param>
        <param-name>compatibilityMode</param-name>
        <param-value>IE=8</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

最新更新