此方式适用于流的形式,不适用于ajax,json

public class ResponseUtil {

    public static void write(HttpServletResponse response,Object o)throws Exception{
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        out.print(o.toString());
        out.flush();
        out.close();
    }
    
    public static void export(HttpServletResponse response,Workbook wb,String fileName)throws Exception{
        response.setHeader("Content-Disposition", "attachment;filename="+new String(fileName.getBytes("utf-8"),"iso8859-1"));
        response.setContentType("application/ynd.ms-excel;charset=UTF-8");
        OutputStream out=response.getOutputStream();
        wb.write(out);
        out.flush();
        out.close();
    }

}

 

相关文章:

  • 2021-07-23
  • 2021-05-25
猜你喜欢
  • 2021-04-03
  • 2021-05-07
  • 2021-12-28
  • 2021-03-30
  • 2021-11-20
  • 2021-04-14
相关资源
相似解决方案