)
其中agent就是请求头User-Agent的值
代码语言:javascript复制if (agent.contains("MSIE")) {
// IE浏览器
filename = URLEncoder.encode(filename, "utf-8");
filename = filename.replace(" ", " ");
} else if (agent.contains("Firefox")) {
// 火狐浏览器
BASE64Encoder base64Encoder = new BASE64Encoder();
filename = "=?utf-8?B?"
base64Encoder.encode(filename.getBytes("utf-8")) "?=";
} else {
// 其它浏览器
filename = URLEncoder.encode(filename, "utf-8");
}