public void download(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setCharacterEncoding("UTF-8"); String filePath = request.getParameter("filePath"); String fileName = request.getParameter("fileName"); if (StringUtils.isNotBlank(fileName)) { response.setContentType("application/force-download");// 应用程序强制下载 String userAgent = request.getHeader("User-Agent"); byte[] bytes = userAgent.contains("MSIE") ? fileName.getBytes() : fileName.getBytes("UTF-8"); fileName = new String(bytes, "ISO-8859-1"); response.setHeader("Content-Disposition", String.format("attachment; filename="%s"", fileName)); } download(filePath, response.getOutputStream()); }