首页 > 代码库 > 解决IE11下载附件文件名乱码问题
解决IE11下载附件文件名乱码问题
/** * 对文件流输出下载的中文文件名进行编码 屏蔽各种浏览器版本的差异性 * @throws UnsupportedEncodingException */ public static String encodeChineseDownloadFileName( HttpServletRequest request, String pFileName) throws UnsupportedEncodingException { String filename = null; String agent = request.getHeader("USER-AGENT"); if (null != agent){ if (-1 != agent.indexOf("Firefox")) {//Firefox filename = "=?UTF-8?B?" + (new String(org.apache.commons.codec.binary.Base64.encodeBase64(pFileName.getBytes("UTF-8"))))+ "?="; }else if (-1 != agent.indexOf("Chrome")) {//Chrome filename = new String(pFileName.getBytes(), "ISO8859-1"); } else {//IE7+ filename = java.net.URLEncoder.encode(pFileName, "UTF-8"); filename = StringUtils.replace(filename, "+", "%20");//替换空格 } } else { filename = pFileName; } return filename; }
另外可以修改下IE的配置,也可以
1.Win + R输入gpedit.msc打开组策略编辑器
2.定位到计算机配置→管理模板→windows组件→Internet Explorer→自定义用户代理字符串
3.双击打开设置已启动,输入字符串“MSIE 9.0”
4.点击确定
5.重启浏览器即可生效
转载至:http://blog.csdn.net/dracotianlong/article/details/22687891
本文出自 “ciyo技术分享” 博客,请务必保留此出处http://ciyorecord.blog.51cto.com/6010867/1934905
解决IE11下载附件文件名乱码问题
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。