1

我有一个带有 jsp 页面的项目,该页面在 tomcat6 服务器上包含一个小测试 SVG。它在 Firefox、IE10 中运行良好。但在 IE9 中,SVG 不显示。有趣的是,当我创建与 html 相同的页面并使用 IE9(不涉及 tomcat)打开它时,它工作正常。

我的网络应用程序中的代码:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
</head>
<body>
    <h1>Hello World!</h1>
    <svg id='svg2' width='500' height='500'>
        <rect x="10" y="10" height="300" width="300" style="fill: #000000" id="bot" />
    </svg>
</body>
</html>

在 IE9 /Firefox 中锁定源代码时,会显示:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>
    <h1>Hello World!</h1>
    <svg id='svg2' width='500' height='500'>
       <rect x="10" y="10" height="300" width="300" style="fill: #000000" id="bot" />
    </svg>
</body>
</html>

当我将此源代码复制到 html 文件中并使用 IE9 打开时,svg 会正确显示。

谁能告诉我如何在 IE9 中使用 tomcat 获得工作 SVG?

谢谢

编辑:

解决方案是在标题中添加以下元标记:

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

谢谢。

4

1 回答 1

0

您需要使用内容类型application/xhtml+xml来说服符合标准的浏览器呈现 SVG。

参考: http: //philarcher.org/diary/svgtest/

于 2013-10-09T17:43:47.827 回答