配置Tomcat发送兼容IE 7或6的网页
我的应用程序不兼容使用 IE8 浏览器。
我正在寻找一种方法来配置运行此应用程序的 Tomcat,以便 IE8 可以读取这些页面,并将其视为 IE7 或 IE6
通过谷歌搜索到目前为止,我发现了一个可能的建议,即添加到 http 响应标题: X-UA 兼容:IE=EmulateIE7
此处
告诉 IE8比如IE7。
问题是这种方式需要添加一个应该在应用程序级别添加的过滤器。我想知道你们中是否有人熟悉 Tomcat 能够发送其 http 内容以兼容 IE7(或 IE6)的更通用的方式?
I have got an application that is not compatible to work using IE8 browser.
I am looking for a way to to configure Tomcat on which this application run, so the pages could be read by IE8 and treated as if they are IE7 or IE6
By googling so far I found a possible suggestion which say to add to the http response the header:
X-UA-Compatible: IE=EmulateIE7
here
that tell IE8 to be like IE7.
The problem is that this way requires adding a filter that should be added on application level. I'd like to know if any of you is familiar with a more generic way that Tomcat enables to send its http content to be IE7 (or IE6) compatible ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Tomcat 是一个通用的 Web 服务器和 servlet 容器。它绝对与浏览器无关,因此无法以某种特殊的方式配置它来处理 IE。
您实际上不必添加过滤器。最低限度是在“service”方法(或 doGet 或 doPost,无论应用程序使用什么)中的任何位置设置响应标头:
res.addHeader("X-UA-Compatible", "IE=EmulateIE7 ");
但这是在服务器应用程序中只有一个入口点的情况下。否则过滤器应该以更好的方式完成这项工作。
Tomcat is a general purpose webserver and servlet container. It is absolutely browser-agnostic thus, there's no way to configure it in some special way to deal with IEs.
You don't have to add filter really. The bare minimum is to set the response header anywhere in "service" method (or doGet or doPost, whatever application uses):
res.addHeader("X-UA-Compatible", "IE=EmulateIE7 ");
But this is in case when there's a single entry point in the server application. Otherwise filter should do the job in a better way.
请参阅此论坛 线程 讨论的情况与您所描述的情况完全相同。看来过滤器是最好的方法。正如上述线程中的答案所示,您可以使用网址重写过滤器。
另外,如果您使用 Apache Web Server 来代理 Tomcat,您可以轻松配置它以向响应添加任何标头。
See this forum thread that discusses exactly the same situation you are describing. It seems that a filter is the best way to go. As an answer at the above thread suggests, you could use Url Rewrite Filter.
Also, if you are using Apache Web Server to proxy Tomcat, you could easily configure it to add any header to the response.