这两天在运维一个项目。项目在测试网上正常,等到部署到正式网上出现乱码问题
当时后台的代码
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"));
系统恢复正常。
时间: 2024-10-14 09:37:18