public static String filenameEncoding(String filename, HttpServletRequest request) throws IOException {
String agent = request.getHeader("User-Agent"); //获取浏览器
if (agent.contains("Firefox")) {
Encoder base64Encoder = Base64.getEncoder();
filename = "=?utf-8?B?"
+ base64Encoder.encodeToString(filename.getBytes("utf-8"))
+ "?=";
} else if(agent.contains("MSIE")) {
filename = URLEncoder.encode(filename, "utf-8");
} else {
filename = URLEncoder.encode(filename, "utf-8");
}
return filename;
}
下载解码
最新推荐文章于 2024-06-21 01:01:27 发布