DWR文件下载

来源:互联网 发布:raphael js 官网 编辑:程序博客网 时间:2024/06/16 01:26

DWR.XML配置文件

 <create creator="spring" javascript="ReportDownloadServer">  
    <param name="beanName" value="ReportDownloadDWR"/>   
</create>

 

jsp文件代码

ReportDownloadServer.downloadERPShowReport(batchid,{
  callback:function(data) {
     dwr.engine.openInDownload(data);
    },
  errorHandler:function(msg, exc){
   alert("Error message is: " + msg + " - Error Details: " + dwr.util.toDescriptiveString(exc, 2));
  }
 });

 

后台服务部分代码

String fileName =  new String(file.getName().getBytes("GBK"), "iso8859-1");

  ByteArrayOutputStream os = null;
  try {
   os = downloadService.loadShowERPReportService(batchid,erpid);
  } catch (RowsExceededException e) {
   throw e;
  } catch (WriteException e) {
   throw e;
  } catch (IOException e) {
   throw e;
  }
return new FileTransfer(fileName + ".xls", "application/msexcel;charset=UTF-8",os.toByteArray()); 

原创粉丝点击