public static String processFileName(HttpServletRequest request, String fileNames) {
String codedfilename = null;
try {
String agent = request.getHeader("USER-AGENT");
if (null != agent && -1 != agent.indexOf("MSIE") || null != agent && -1 != agent.indexOf("Trident")) {
// IE
codedfilename = java.net.URLEncoder.encode(fileNames, "UTF8");
} else if (null != agent && -1 != agent.indexOf("Mozilla")) {
// 火狐,CHROME等
codedfilename = new String(fileNames.getBytes("UTF-8"), "iso-8859-1");
}
} catch (Exception e) {
e.printStackTrace();
}
return codedfilename;
}
调用工具类处理一下即可