SpringMVC生成Excel和PDF檔案時檔名亂碼的解決方案
阿新 • • 發佈:2019-01-10
解決下載的檔名為中文時的亂碼問題:
//將程式碼
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(excelName, "UTF-8"));
//修改為
response.setHeader("Content-Disposition", "attachment;filename=" + new String(excelName.getBytes("gbk"),"ISO-8859-1"));