解决方式有两种,如下
(1)标红即为中文乱码的处理方式
rsp.setHeader("Content-Disposition", "attachment;fileName=" + java.net.URLEncoder.encode(fileInfo.getName(), "UTF-8"));rsp.setCharacterEncoding("utf-8");rsp.setContentType("multipart/form-data");
(2)这种方式之前是管用的,不知什么原因,现已失效
rsp.setCharacterEncoding("utf-8");rsp.setContentType("multipart/form-data");rsp.setHeader("Content-Disposition", "attachment;fileName=" + new String(fileInfo.getName().getBytes("utf-8"), "iso-8859-1"));
原文地址:https://www.cnblogs.com/lzq930/p/12564243.html
时间: 2024-10-27 17:14:54