Commit c5b29911 authored by Quxl's avatar Quxl
parents 9643dbbf 59d59db7
package com.egolm.common.web;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.util.Enumeration;
......@@ -69,4 +71,18 @@ public class ServletUtil {
return json;
}
}
public static String covertFileName(HttpServletRequest request, String fileName)throws UnsupportedEncodingException {
String userAgent = request.getHeader("User-Agent").toLowerCase();
System.out.println(userAgent);
String excelFileName = "";
if (userAgent.indexOf("msie") != -1) {// IE浏览器
excelFileName = URLEncoder.encode(fileName, "UTF8");
} else if (userAgent.indexOf("firefox") != -1) {// google,火狐浏览器
excelFileName = new String(fileName.getBytes(), "ISO-8859-1");
} else {
excelFileName = URLEncoder.encode(fileName, "UTF8");// 其他浏览器
}
return excelFileName;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment