小弟最近做了一个用servlet,完成上传文件,和对文件转换成swf文件后返回客户端的操作。
前部分都做好了,就是后面读取转换好的swf文件然后写回客户端这里出现问题,客户端页面总显示没有加载影片,ie中使用的是flash10的插件。我的代码是
File outFile = new File(outputFilePath);
if (outFile.exists()) {
//向客户端写回文件
if (outputExtension.equalsIgnoreCase("pdf")) {
response.setContentType("application/pdf");
} else if (outputExtension.equalsIgnoreCase("swf")) {
response.setHeader("Content-Length", ""
+ outFile.length());
response.setContentType("application/x-shockwave-flash");
}
// response.setHeader("Content-Disposition", "inline; filename="
// + outputFileName);
FileInputStream is = new FileInputStream(outputFilePath);
PrintWriter pw = response.getWriter();
int k;
while ((k = is.read()) != -1) {
pw.write(k);
}
pw.flush();
pw.close();
is.close();
is = null;
如果是pdf的话IE中可以正常显示,就是swf文件,IE中显示的是flash资源,但是没有影片。
右键点击页面就像下面一样显示

希望大家给点帮助