下载文件名乱码

	/**
	 * @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;
	}

猜你喜欢

转载自longload.iteye.com/blog/2127002