response.getOutputStream().write(new String(content,0,字节长度);

解决方案 »

  1.   

    上面错了改为response.getOutputStream().write(content,0,字节长度); 试试看。
      

  2.   

    PrinterWriter pw = response.getOutputStream();
    然后用pw.write()来写,
    如果还不行把你的content里的东西转一下码,之后写进去
      

  3.   

    public void writeToHttpServletResponseWithDownloadFile(javax.servlet.http.
          HttpServletResponse response) throws java.io.IOException
      {
        response.setContentType(this.getContentType());
        response.addHeader("Accept-Ranges", "bytes");
        response.addHeader("Accept-Length", String.valueOf(this.content.length));
        response.addHeader("Content-Disposition",
                           "attachment; filename=\"" + this.name + "\"");
    //    response.setContentType("text/html;charset=GBK");
        System.out.println("content:"+new String(content,"GBK")+"  content.length:"+content.length);
        response.getOutputStream().write(this.content,0,content.length);
        response.getOutputStream().flush();
        response.getOutputStream().close();
      }
    content是文件内容,是对的
    文件名是this.name,传过去是乱码
      

  4.   

    PrinterWriter pw=response.getOutputStream();
    这要报错的嘛