标签: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));
}
标签:filename nload iso tchar coding ace utf-8 index ring
原文地址:https://www.cnblogs.com/zxg-blog/p/13168786.html