?目前尚未处理文件中有中文的情况.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // response.setContentType("text/html"); // response.setHeader("Content-disposition","attachment;filename="+"你.doc"); //通知客户要下载文件类型 // response.setContentType("application/msword"); response.setContentType("application/octet-stream;charset=UTF-8"); String filename2=new String("测试.doc".getBytes("utf-8"),"iso-8859-1"); response.setHeader("Content-disposition","attachment;filename="+ filename2 + ""); PrintWriter out = response.getWriter(); out .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.print(" This is "); out.print(this.getClass()); out.println(", using the GET method"); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); }
?