文件下载时弹出的文件名乱码问题

		response.reset();
		HttpServletRequest request = this.getRequest();
		response.setContentType(contentType);
		String agent = request.getHeader("USER-AGENT");
		if (null != agent && -1 != agent.indexOf("MSIE")) {// IE
			// 设置文件头,文件名称或编码格式
			response.addHeader("Content-Disposition",
					"attachment;filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8") + "\"");
		} else {// firefox
			response.addHeader("Content-Disposition",
					"attachment;filename=\"" + new String(fileName.getBytes("UTF-8"), "ISO-8859-1") + "\"");
		}
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页