当前位置: 首页 > news >正文

怎么自己做网站卖东西哪些网站可以做招生

怎么自己做网站卖东西,哪些网站可以做招生,用户体验 网站 外国,上海市招投标公共信息服务平台业务背景#xff1a; 在开发过程中#xff0c;我们会遇到需要对文件#xff08;单个或多个#xff09;进行压缩并下载的功能需求#xff0c;这里记录一下压缩多个文件的实现过程#xff0c;或许有更好的方式请大家补充 前端实现一个按钮调下载压缩包的接口 button…业务背景 在开发过程中我们会遇到需要对文件单个或多个进行压缩并下载的功能需求这里记录一下压缩多个文件的实现过程或许有更好的方式请大家补充 前端实现一个按钮调下载压缩包的接口 button icondownload typeprimary clickdownload下载压缩包 buttonscriptdownload () {location.href faceConfig.basePath /download? fileIds paramData.fileIds //业务参数,根据实际情况写}, /script 后端接口实现 controller控制层定义下载压缩包接口 GetMapping(download)public void download(String fileIds){readService.download(fileIds,getResponse());} 定义service服务层接口  public interface ReadService {void download(String fileIds, HttpServletResponse response); } 定义服务层接口实现类  Overridepublic void download(String fileIds, HttpServletResponse response) {String[] Ids fileIds.split(,);Map map new HashMap();Map bas64Map new HashMap();File[] file new File[Ids.length];File file1 null;OutputStream output null;BufferedOutputStream bufferedOutput null;FileInputStream inStream null;try {for (int i 0; i Ids.length; i) {// 1.获取到要压缩的文件这里是自己的业务逻辑可根据实际情况去写只要最后能拿到file就行Map paramMap new HashMap();paramMap.put(Id, Ids[i]);map certificatePrintReadMapper.getFileInfo(paramMap);bas64Map WaterMarkUtils.createStringMark(map);String base64 (String) bas64Map.get(qj);byte[] bytes decode(base64);file1 new File(Ids[i] 证书.jpg);output new FileOutputStream(file1);bufferedOutput new BufferedOutputStream(output);bufferedOutput.write(bytes);// 2。文件放到文件数组里file[i] file1;output.close();bufferedOutput.close();}// 3.创建压缩文件将文件数组进行压缩File zip new File(压缩包名字.zip);// 压缩文件zipFiles(file, zip);response.setContentType(*/*);response.addHeader(Content-Disposition, attachment;filename new String(压缩包名字.zip.getBytes(), ISO8859-1));ServletOutputStream outputStream response.getOutputStream();inStream new FileInputStream(zip);byte[] buf new byte[4096];int readLength;while (((readLength inStream.read(buf)) ! -1)) {outputStream.write(buf, 0, readLength);}inStream.close();outputStream.flush();outputStream.close();} catch (IOException e) {e.printStackTrace();} finally {if (bufferedOutput ! null) {try {bufferedOutput.close();} catch (IOException e) {e.printStackTrace();}}if (inStream ! null) {try {inStream.close();} catch (IOException e) {e.printStackTrace();}}}}//子方法压缩文件public static void zipFiles(File[] srcfile, File zipfile) {byte[] buf new byte[1024];FileInputStream in null;try {ZipOutputStream out new ZipOutputStream(new FileOutputStream(zipfile), StandardCharsets.UTF_8);//File file2 null;for (int i 0; i srcfile.length; i) {String filename srcfile[i].getName();in new FileInputStream(srcfile[i]);out.putNextEntry(new ZipEntry(filename));int len;while ((len in.read(buf)) 0) {out.write(buf, 0, len);}// out.setEncoding(GBK);out.closeEntry();in.close();System.out.println(srcfile[i].delete());}out.close();} catch (IOException e) {//e.printStackTrace();} finally {try {if (in ! null) {in.close();}} catch (IOException e) {//e.printStackTrace();}}}//子方法将Base64转成字节数组public static byte[] decode(String str) {byte[] b null;String result null;if (str ! null) {BASE64Decoder decoder new BASE64Decoder();try {b decoder.decodeBuffer(str);// result new String(b, utf-8);} catch (Exception e) {}}return b;} 这样就实现了一个将多个文件进行压缩并下载的功能啦
http://www.zqtcl.cn/news/546180/

相关文章:

  • flash做网站步骤中国网评中国网评
  • 网站添加备案号比较好的网站建设公司
  • 旅游电子商务网站建设目的广告设计与制作主修课程
  • 网站标题写什么作用记事本做网站如何添加图片
  • 海口建站模板厂家下载什么网站做吃的
  • 网站建设的指导书动效网站建设
  • 万州做网站的公司wordpress练习
  • 网站域名dnsgoogle推广教程
  • 网站建设报价方案doc网站建设seo视频教程
  • 北京免费建站网络营销怎么做查询网站后台
  • 深圳外贸网站推广用html制作个人博客
  • 建设银行网站最近打不开吗wordpress c
  • 网站icp备案费用浅谈做网站的好处
  • 制作网站需要懂哪些在线设计平台的市场调研
  • 接计设做的网站河南网站建设华企祥云
  • 网站系统维护一般要多久企业网站推广工具
  • 如何诊断网站seo做个网站商场需要多少
  • 腾讯云做视频网站吗创业商机网加工项目
  • 网站建设论文文献郑州seo外包费用
  • 网站优化西安如何免费推广网站
  • 固原市建设局网站外贸网站建设方法
  • 做违规网站主页制作语言缩写
  • 汝南县网站建设怎么注册公司钉钉账号
  • 网站建设酷隆信通网站开发中心
  • 保定网站建设方案报价怎么做网站_
  • 做网站功能的框架结构图做网站用python好吗
  • 襄樊市网站建设模版网站建设企业
  • 网站换服务器php大流量网站开发规范
  • 网站备案主体域名平面设计线下培训班多少钱
  • 优秀网站专题wordpress 外部调用插件