web 下载文件

用户可指定下载地址,此时用要HttpServletResponse的输出流

String fileName = "名称-"+ dateUtil.getCurrentTime(DateFormat.YYYYMMDDHHMMSS) + ".xls";

response.setContentType("application/unknown; charset=GB2312");
response.setHeader("content-disposition", "attachment;filename=" + new String(fileName.getBytes("GB2312"), "iso-8859-1"));

OutputStream os = response.getOutputStream();

。。。

你可能感兴趣的:(java基础)