我们的应用程序无法与IE11
和EM
一起运行。我们正在使用Modify JSF-1.2 和 RichFaces 3.X 。当我们在没有EM的情况下在 IE11上运行Web网页时,所有工作正常,但是我们必须将IE11
与EM
一起使用。有什么可能的方法对代码禁用页面的EM?IE
控制台引发错误:“XML5632:仅允许一个根元素。”在页面之间移动时发生。
PS:在IE8
,IE9
和IE11
上运行的应用程序没有任何问题,但是当您尝试使用IE11
和EM
时,它出现了错误。
最佳答案
解决此问题的方法不是从服务器上打磨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);
}
}
}