// 判断浏览器 HttpServletRequest request = ServletActionContext.getRequest(); String Agent = request.getHeader("User-Agent"); if (null != Agent) { Agent = Agent.toLowerCase(); if (Agent.indexOf("firefox") != -1) { filename = new String(doc.getSubject().getBytes(),"iso8859-1"); } else if (Agent.indexOf("msie") != -1) { filename = java.net.URLEncoder.encode(doc.getSubject(),"UTF-8"); } else { filename = java.net.URLEncoder.encode(doc.getSubject(),"UTF-8"); } }
//乱码出现的原因 ie采用URLEncoder编码输出中文 opera采用filename safari采用iso-8859-1 chrome采用base64或iso-8859-1 firefox采用base64或iso-8859-1