批量导出记录,并且将内存中数据转换html,然后压缩成Zip下载。

该功能主要是实现,将记录批量转换html然后,打包压缩成zip包下载。 

 

public final ActionForward resume2Export(ActionMapping actionMapping,
   ActionForm form, HttpServletRequest request,
   HttpServletResponse response) throws Exception {
  
  String act = request.getParameter("act");

  if (act.equals("count2zip")) {// 面试查询导出Zip
   
   response.reset();
   response.setContentType("application/zip");
   String today=java.text.DateFormat.getDateInstance().format(new java.util.Date());
   response.setHeader("Content-disposition","attachment;filename=t1_"+today+".zip" );

         try {
          int BUFFER = 2048;
             BufferedInputStream origin = null;

             ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
             byte data[] = new byte[BUFFER];
           

             for(int i=0; i<3; i++){

                    InputStream fi = new ByteArrayInputStream("aaaaaaaaaaaaaa".getBytes());
              
                 origin = new BufferedInputStream(fi, BUFFER);
                 ZipEntry entry = new ZipEntry("a"+i+"你好.html");
                 out.putNextEntry(entry);
                 int count;
                 while ((count = origin.read(data, 0, BUFFER)) != -1) {
                     out.write(data, 0, count);
                 }
                 origin.close();
             }
             out.close();
         } catch (Exception e) {
             e.printStackTrace();
         }   
   
   
   PageContext pageContext = JspFactory.getDefaultFactory()
     .getPageContext(this.getServlet(), request, response,null, true, 8192, true);
   
   JspWriter out = pageContext.getOut();
   out.clear();
   out = pageContext.pushBody();
  }
  
  return null;

  
 } 

你可能感兴趣的:(html,面试)