有没有把 Content Type 设置为 application/x-download
设置 content type 的那个方法名我记不得了,你查查文档,应该好找的。
查 HttpResponse 里的吧。

解决方案 »

  1.   

    把 Content Type 设置为 application/x-download不行啊
    文件被直接打开了
    请问还有什么方法吗
    谢谢
      

  2.   

    把 Content Type 设置为 application/x-download
    同时还要设置下面这个
    httpServletResponse.setHeader("Content-disposition","attachment; filename=测试.txt");---------
    response.setContentType("application/x-download");
    //或者
    //response.setContentType("application/octet-stream");
    String filename = response.encodeUrl("文件名.txt");  // 不知道这句话有没有必要,试试吧。
    response.setHeader("Content-Disposition", "attachment; filename=" + filename);
      

  3.   

    String filename = response.encodeUrl("文件名.txt");  
    这句话要改一下
    String filename = java.net.URLEncoder.encode("文件名.txt", "UTF-8");
      

  4.   

    to:zoutaosss (虾米)
    我也遇到了同样的问题,不知道你解决了没有,我们能否交流一下
    [email protected]