使用response.setHeader("Content-Disposition","attachment;filename="+fName)下載文件,中文文件名無法顯示


 這是部分代碼
response.setContentType("application/msword");
String uncod= URLDecoder.decode(fileName);
fileName = new String(uncod.getBytes("UTF-8"), "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=".concat(String.valueOf(fileName)));
這樣寫中文會丟失

改成如下
fileName = new String(uncod.getBytes(), "ISO-8859-1");
便可解決


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM