文件下载

    @RequestMapping(value = "/refundDepositDownload")
    public void download(HttpServletRequest request, HttpServletResponse  response) {
        String key=request.getParameter("key");
        RBinaryStream io=redissonClient.getBinaryStream(key);
        try {
            String fileName=new String("待退保证金列表".getBytes("gb2312"), "ISO8859-1");
            response.reset();
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition", "attachment;filename=\"" +  fileName+ ".xls" + "\"");
            ServletOutputStream out=response.getOutputStream();
            out.write(io.get());
            out.flush();
        } catch (Exception e) {
            log.error("下载excel发生异常", e);
        }
    }

 

你可能感兴趣的:(文件下载)