最近在做一个在线文档阅读系统,用swftools将pdf转换成swf后,将swf的绝对地址传到一个jsp页面,但在浏览器中就是加载不出来这个swf文件。。如果用html页面来加载这个swf文件的话能显示出来。好了,不多说了上显示页面代码:
<%@ page language="java"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>阅读文档</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
<% 
String swfPath = (String)application.getAttribute("swfPath"); 
out.println(swfPath); 
 %>
   <div align = "center">
   <embed src="<%=swfPath%>" quality="high" wmode="transparent" bgcolor="#ffffff" width="1200" height="1000" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </div>
  </body>
</html>另外用IE打开上面这个无法显示SWF得JSP页面,查看源代码,src的路径也是对的。。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="http://127.0.0.1:8080/MywebStudy/">
    
    <title>阅读文档</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
  </head>
  
  <body>
D:\attachment\swf\Start_实习报告.swf
 
   <div align = "center">
   <embed src="D:\attachment\swf\Start_实习报告.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="1200" height="1000" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> 
 
</div>
  </body>
</html>

解决方案 »

  1.   

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort()
    + path + "/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    </head> <body>
    <body>
    <%
    //String swfPath = (String) application.getAttribute("swfPath");
    //out.println(swfPath);
    %>
     
    <div align="center">
    <embed src="source/test1.swf" quality="high" wmode="transparent"
    bgcolor="#ffffff" width="1200" height="1000" align="middle"
    allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </div>
    </body>
     
    </html>我这边可以啊,把你的swf文件放到WebRoot下。用相对路径试试。
      

  2.   

    直接运行html网页是可以加载出来的,但是发布到tomcate服务器就没有显示了,是否有什么属性需要设置呢?