【问题标题】:To programmatically disable IE-8 compatibility mode for the site running in intranet and rendering .xhtml pages以编程方式为在 Intranet 中运行并呈现 .xhtml 页面的站点禁用 IE-8 兼容模式
【发布时间】:2014-03-11 03:04:56
【问题描述】:

我有一个在 Intranet 中运行的带有 .xhtml 页面的 JSF 应用程序。我尝试删除默认元标记并添加元标记

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

但是没有用。这个解决方案仅适用于普通的 html 页面,还是有任何其他方法可以通过编程方式禁用兼容模式。

【问题讨论】:

    标签: java internet-explorer jsf-2 internet-explorer-8 ie8-compatibility-mode


    【解决方案1】:

    如果您想阻止所有 JSF 页面的兼容模式,您最好为此使用过滤器:

    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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-17
      • 2019-03-06
      • 2011-04-26
      • 2014-04-11
      • 2011-03-07
      • 2011-10-02
      • 2013-03-23
      • 2013-05-15
      相关资源
      最近更新 更多