jsp文件下载,中文文件名

分ie和firefox/oprea不同而不同,红色部分解决编码后空格变+号的问题。
String browser = request.getHeader("user-agent");
    Pattern pattern = Pattern.compile(".* MSIE.*?;.*");
	Matcher matcherAccount = pattern.matcher(browser);
	if(matcherAccount.matches()){
		response.setHeader("Content-Disposition","attachment;filename=\""+ [color=red]StringUtils.replace[/color](java.net.URLEncoder.encode(downloadname),"+","%20") + "\"");
	}else{
		response.setHeader("Content-Disposition", "attachment;filename=\""+ new String(downloadname.getBytes("UTF-8"),"ISO8859-1")+ "\"");
	}

你可能感兴趣的:(java,.net,jsp,IE,firefox)