这两天在运维一个项目。项目在测试网上正常,等到部署到正式网上出现乱码问题
当时后台的代码
response.setContentLength(outData.length); response.setHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(), "utf-8")); ServletOutputStream sos = response.getOutputStream(); sos.write(outData);
最后修改为
response.setContentType("application/x-msdownload"); response.setContentLength(outData.length); response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode( fileName,"utf-8"));
系统恢复正常。
原文地址:http://xiaowei1989.blog.51cto.com/3971791/1613442