文件下载时,文件名乱码问题
作者:互联网
文件下载时,解决不同浏览器文件名乱码问题
public static String encodeFileName(HttpServletRequest request, String pFileName) { String userAgent = request.getHeader("USER-AGENT"); try { if (userAgent.contains("msie") || userAgent.contains("like gecko")) { pFileName = URLEncoder.encode(pFileName, "utf-8"); } else { pFileName = new String(pFileName.getBytes("utf-8"), "iso8859-1"); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return pFileName; }
标签:utf,String,文件名,contains,乱码,下载,userAgent,pFileName 来源: https://www.cnblogs.com/jane-long/p/10711456.html