(JSP)关于⼿机端(尤其是苹果⼿机)pdf⽂件⽆法打开的解
决⽅案
流的⽅式下载附件
<!--
@author :daisy
@date : 2011-12-04
@note : 从数据库中读取BLOB图⽚显⽰
-->
<%@page import="com.cwai.dao.DBManager"%>
<%@ page contentType=" text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
out.clear();
out = pageContext.pushBody();
//读取blob字段的图⽚内容,将其显⽰
String xh = Parameter("xh");
String wjm = Parameter("wjm");
wjm = de(wjm, "UTF-8");
try {
ServletOutputStream sos = null;
String sql = "SELECT WJNR WJNR FROM FJ_SWYB WHERE XH = '" + xh+"'";
System.out.println(sql);
byte[] blob_array = Blob(sql, null);
try {
//修改前
//response.setContentType("multipart/form-data");
//修改后
response.setContentType("multipart/form-data");
String kzm = wjm.substring(wjm.lastIndexOf(".")+1);
if("PDF".UpperCase()) ){
response.setContentType("application/pdf");
}
String downFileName = new Bytes("GB2312"),"iso8859-1");
//注意:attachment \inline 两者的区别
html手机网站 response.setHeader("Content-Disposition", "attachment;filename=\""+downFileName+"\"");
sos = OutputStream();
System.out.println("blob_array-lenth:----" + blob_array.length);
sos.write(blob_array);
sos.flush();
sos.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (sos != null) sos.close();
}
return;
} catch (Exception ex) {
ex.printStackTrace();
}
response.sendError(404);
%>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论