当前位置: 代码迷 >> JavaScript >> JSP文件上载,文件名中文乱码有关问题解决方案
  详细解决方案

JSP文件上载,文件名中文乱码有关问题解决方案

热度:99   发布时间:2012-09-02 21:00:34.0
JSP文件下载,文件名中文乱码问题解决方案.
?目前尚未处理文件中有中文的情况.
	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();
	}

?

  相关解决方案