public ActionForward downxls(ActionMapping mapping,ActionForm form,HttpServletRequest request,
HttpServletResponse response){
String filename ="anya";
response.reset();
response.resetBuffer();
response.setContentType("Application/msexcel;charset=gb2312");
//response.setHeader("Content-disposition","attachment;filename=" +filename+".xls");
//response.addHeader("Content-Disposition", "filename="+filename+".xls");
String filepath =FileProper.getFilePathPro("anyang_jdz");
//String filepathout="C:\\Documents and Settings\\Administrator\\桌面\\";
try{
FileInputStream fileInputStream =new FileInputStream(filepath + filename);
//OutputStream fileOut=response.getOutputStream(new FileOutputStream(filepathout+filename));
OutputStream out=response.getOutputStream();
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.flush();
out.close();
}catch(Exception e){
Log.errorLog(e);
e.printStackTrace();
}
return go_list(mapping,form,request,response);
}
但是在同一个jsp页面实现生成报表和下载到本地时,只能生成而下载到本地时是当前jsp页面的内容,面没有把报表给下载下来?
我想问一下怎么解决!
请高手们多指点!
HttpServletResponse response){
String filename ="anya";
response.reset();
response.resetBuffer();
response.setContentType("Application/msexcel;charset=gb2312");
//response.setHeader("Content-disposition","attachment;filename=" +filename+".xls");
//response.addHeader("Content-Disposition", "filename="+filename+".xls");
String filepath =FileProper.getFilePathPro("anyang_jdz");
//String filepathout="C:\\Documents and Settings\\Administrator\\桌面\\";
try{
FileInputStream fileInputStream =new FileInputStream(filepath + filename);
//OutputStream fileOut=response.getOutputStream(new FileOutputStream(filepathout+filename));
OutputStream out=response.getOutputStream();
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.flush();
out.close();
}catch(Exception e){
Log.errorLog(e);
e.printStackTrace();
}
return go_list(mapping,form,request,response);
}
但是在同一个jsp页面实现生成报表和下载到本地时,只能生成而下载到本地时是当前jsp页面的内容,面没有把报表给下载下来?
我想问一下怎么解决!
请高手们多指点!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货