IE Chrome 火狐乱码空格解决

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));
}
posted @ 2020-06-20 15:09  0o飞行天下o0  阅读(324)  评论(0编辑  收藏  举报