直接通过Response输出流写文件,浏览器表现为下载文件

response.setContentType("application/x-download");
response.addHeader("Content-Disposition", "attachment;filename="+new String( "中文".getBytes("utf-8"), "ISO8859-1" )+"文件类型");

OutputStream out = response.getOutputStream();

向out中写入流

out.flush();

response.flushBuffer();

即可

posted @ 2015-07-17 16:33  光闪  阅读(9478)  评论(0编辑  收藏  举报