lxw
2022-09-01 b848451e8889fea12ce40b7818c1b8d84b50ea02
src/main/java/com/whyc/service/ProductSoftwareService.java
@@ -20,6 +20,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
@@ -56,7 +57,7 @@
        try {
            // 转码防止乱码
            //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1"));
            resp.setHeader("Content-Disposition", "attachment;filename* = UTF-8''" +  new String(softwareName.getBytes("UTF-8"), "ISO8859-1"));
            resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( softwareName, "utf-8"));
            OutputStream out = resp.getOutputStream();
            FileInputStream in = new FileInputStream(fileDirName+File.separator+software.getSoftwareUrl());
            int len=0;
@@ -80,6 +81,14 @@
        logService.recordOperationLog(docUser.getId(),docUser.getName(), UserOperation.TYPE_DOWNLOAD.getType(),new Date(),terminalIp,opreationMsg,operationDetail);
    }
    public void insert(ProductSoftware productSoftware) {
        mapper.insert(productSoftware);
    }
    public List<ProductSoftware> getAll() {
        return mapper.selectList(null);
    }
    public static void main(String[] args) throws UnsupportedEncodingException {
        String softwareName="散装件.zip";
        //ISO8859-1 UTF-8