win2000环境下IE6下Adobe Reader8下打开或者下载pdf文件是没有问题的。
但是在xp环境下IE7下Adobe Reader8下打开pdf文件也没有问题,但是下载pdf文件时就有问题了。表现形式是:一直下载中,却下载不下来。
下载的代码如下:
SystemParameter systemParameter = (SystemParameter)request.getAttribute("systemParameter");
BookListCondition blc = (BookListCondition)request.getAttribute("bean");
if(blc != null){
String doc_name = blc.getDoc_name();
String downFilename = doc_name;
String filepath = systemParameter.getSavedPDFPath() + doc_name;
File f = new File(filepath);
if(!f.isFile()){
out.print("<script>alert('PDFの書類は存在しない');window.close();</script>");
return;
}
out.clear();
out = pageContext.pushBody();
downFilename = new String(downFilename.getBytes("shift-jis"), "ISO-8859-1");
response.setContentType("application/pdf;charset=shift-jis");
response.setHeader("Location",downFilename);
response.setHeader("Content-Disposition", "attachment; filename=" + downFilename);
InputStream inputStream = new FileInputStream(filepath);
OutputStream outputStream = response.getOutputStream();
byte[] buffer = new byte[1024];
int i = -1;
while ((i = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, i);
}
outputStream.flush();
outputStream.close();
inputStream.close();
}
另补充一点现象:
在下载的过程中,我在Action里设置断点后,在xp环境下IE7下就可以成功下载了。
很是奇怪,还没找到头绪。
急等中............
跟你程序没关系,是操作系统和IE设置的问题,看这个:
[url]http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3310202&SiteID=1[/url]
另外,如果可以找一台别的机子试试就行了