我们的应用程序无法与IE11EM一起运行。我们正在使用Modify JSF-1.2 RichFaces 3.X 。当我们在没有EM的情况下在 IE11上运行Web网页时,所有工作正常,但是我们必须将IE11EM一起使用。有什么可能的方法对代码禁用页面的EM?
IE控制台引发错误:“XML5632:仅允许一个根元素。”在页面之间移动时发生。

PS:在IE8IE9IE11上运行的应用程序没有任何问题,但是当您尝试使用IE11EM时,它出现了错误。

最佳答案

解决此问题的方法不是从服务器上打磨XHTML,而是本机HTML。这提供了将响应从application/xhtml+xml更改为text/html的过滤器。过滤用户代理的获取响应表单头,并查找是否设置了„compatible; msie 8.0“,这意味着IE11在企业模式下运行并模拟IE8

我们实现的解决方案:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

   String userAgent = ((HttpServletRequest) request).getHeader("user-agent");

   if (userAgent != null && userAgent.toLowerCase().contains("compatible; msie 8.0"))
    {
     chain.doFilter(request, new ForcableContentTypeWrapper((HttpServletResponse) response));
    }
    else
    {
     chain.doFilter(request, response);
    }
}

private class ForcableContentTypeWrapper extends HttpServletResponseWrapper
{
     public ForcableContentTypeWrapper(HttpServletResponse response)
    {
    super(response);
    }

    @Override
    public void setContentType(String type)
    {
      if (type.contains("application/xhtml+xml"))
    {
        super.setContentType(type.replace("application/xhtml+xml",
                                          "text/html"));
    }
    else
    {
      super.setContentType(type);
    }

     }
 }

07-25 22:38
查看更多