处理中文文件名下载问题
?
?String filePath = super.realPath + URLDecoder.decode(URLDecoder.decode((String) form.get("openFilePath"),?'UTF-8'),?'UTF-8');
?? ? ? ?File dFile = new File(filePath);
?? ? ? ?FileInputStream fis = new FileInputStream(dFile);
?
?? ? ? ?this.getResponse().reset();
?? ? ? ?this.getResponse().setContentType("Application/Octet-Stream");
?? ? ? ?String fileName = URLDecoder.decode(URLDecoder.decode((String) form.get("openFileName"), KamsConst.SERVER_ENCODING), KamsConst.SERVER_ENCODING);
?? ? ? ?this.getResponse().setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, 'UTF-8'));
?? ? ? ?OutputStream os = this.getResponse().getOutputStream();
?
?? ? ? ?byte[] b = new byte[1024];
?? ? ? ?int real = fis.read(b);
?? ? ? ?while (real > 0) {
?? ? ? ? ? ?os.write(b, 0, real);
?? ? ? ? ? ?real = fis.read(b);
?? ? ? ?}
?? ? ? ?os.close();
?? ? ? ?fis.close();
?? ? ? ?return RESULT_SUCCESS;