下载文件名乱码问题(兼容各种浏览器)

try {
	this.filename = new String("哈哈.xls");
	//判断是否是IE11
        String userAgent = ServletActionContext.getRequest().getHeader("User-Agent").toLowerCase();
            if (userAgent.indexOf("msie") >0 || userAgent.contains("trident") || userAgent.indexOf("edge")>0){
               filename = URLEncoder.encode(filename, "UTF-8");//IE浏览器
            }else {
            	filename = new String(filename.getBytes("UTF-8"), "ISO8859-1");
            }
	} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
}

 

你可能感兴趣的:(IE)