您的位置:首页 > 其它

下载文件名乱码

2016-07-12 00:00 316 查看
/**
* @return the downloadFileName
* @throws UnsupportedEncodingException
*/
public String getDownloadFileName() throws UnsupportedEncodingException {

// 下载文件名(中文需转码)
String name = getRequest().getParameter("name");
//转换编码
this.downloadFileName=WebUtils.convertEncodingToUTF8(name);//非必须
//下载文件,Firefox 特殊处理
if (getRequest().getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0) {
this.downloadFileName = "=?UTF-8?B?" + (new String(Base64.encode(this.downloadFileName.getBytes("UTF-8")))) + "?=";
} else{
this.downloadFileName = java.net.URLEncoder.encode(this.downloadFileName, "UTF-8");
}
return  this.downloadFileName;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: