码迷,mamicode.com
首页 > 其他好文 > 详细

IE Chrome 火狐乱码空格解决

时间:2020-06-20 15:43:15      阅读:47      评论:0      收藏:0      [点我收藏+]

标签:filename   nload   iso   tchar   coding   ace   utf-8   index   ring   

boolean isMSIE = isIE(request);
if (isMSIE) {
//IE浏览器的乱码问题解决
zlmc = URLEncoder.encode(zlmc, "UTF-8");
zlmc=zlmc.replace("+"," ");
} else {
//万能乱码问题解决
zlmc = new String(zlmc.getBytes("UTF-8"), "ISO-8859-1");
}

File file = new File(jbxx.getWjlj() + "/" + downloadFileName);
response.setContentType("application/octet-stream");
if(request.getHeader("USER-AGENT").toLowerCase().indexOf("firefox") > -1){
response.setHeader("Content-disposition","attachment;filename=\"" + zlmc + "\"");
}else {
response.setHeader("Content-Disposition", "attachment; filename=" + zlmc);
}
response.setCharacterEncoding("UTF-8");


public boolean isIE(HttpServletRequest request) {
return ((request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0) || (request
.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0));
}

IE Chrome 火狐乱码空格解决

标签:filename   nload   iso   tchar   coding   ace   utf-8   index   ring   

原文地址:https://www.cnblogs.com/zxg-blog/p/13168786.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!