java做导出的时候,如下写的怎么弹不出文件保存对话框,而是直接下载?
OutputStreamout=null;BufferedOutputStreambos=null;try{Stringxml=this.uspsExport.execu...
OutputStream out = null;
BufferedOutputStream bos = null;
try {
String xml = this.uspsExport.executeExportUspsXml(exportParams);
String fileName = "usps"+new Date().getTime()+".xml";
response.reset();
response.setContentType("text/xml");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
out = response.getOutputStream();
bos = new BufferedOutputStream(out);
bos.write(xml.getBytes());
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
bos.flush();
bos.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
} 展开
BufferedOutputStream bos = null;
try {
String xml = this.uspsExport.executeExportUspsXml(exportParams);
String fileName = "usps"+new Date().getTime()+".xml";
response.reset();
response.setContentType("text/xml");
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
out = response.getOutputStream();
bos = new BufferedOutputStream(out);
bos.write(xml.getBytes());
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
bos.flush();
bos.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询