public String printCustomerDetails() throws Exception{
List<CustomerDetails> printCustomerDetailsListInformation=customerDetailsBizImpl.CustomerDetailsGetAllRecord(
(String)session.getAttribute("customerDetailsGetSmcdClientCode"),
(String)session.getAttribute("customerDetailsGetSmcdName"),
(String)session.getAttribute("customerDetailsGetSmcdTheCompanyProperites"),
(String)session.getAttribute("customerDetailsGetSmcdWayToTrade"),
(String)session.getAttribute("customerDetailsGetSmcdQualityRating"),
(String)session.getAttribute("customerDetailsGetSmcdCreationTime"),
(String)session.getAttribute("customerDetailsGetSmcdModificationTime"));
session.setAttribute("printCustomerDetailsListInformation", printCustomerDetailsListInformation);
List clients=(List)session.getAttribute("printCustomerDetailsListInformation");
Excel ex=new Excel();
try {
String tempfileName = new String("项目报表.xls".getBytes("GBK"),"ISO8859_1");
response.setContentType("application/vnd.ms-excel");
response.setHeader("ContentDisposition", "attachment;filename="+tempfileName);
String webPath = request.getSession().getServletContext().getRealPath("/");
System.out.println(webPath);
//创建一个存放下载文件的临时目录
String tempFile = "tempDownLoad";
File f= new File(webPath + "/" + tempFile);
if(!f.exists()){
f.mkdirs();
}
ex.writeExcelCustomerContact(new FileOutputStream(f), clients);
} catch (Exception e1) {
e1.printStackTrace();
throw new RuntimeException("数据导出时发生错误!",e1);
}
return "success";
}
运行到下面就报错
response.setContentType("application/vnd.ms-excel");
response.setHeader("ContentDisposition", "attachment;filename="+tempfileName);