Commit 5a3916c3 authored by yanzg's avatar yanzg

接口文档的支持

parent ef029db4
......@@ -5,13 +5,15 @@ import com.yanzuoguang.util.helper.HttpHelper;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
/**
* HTTP文件
*
* @author 颜佐光
*/
public class HttpFileHelper extends HttpHelper {
/**
* 下载文件
*
......@@ -25,8 +27,12 @@ public class HttpFileHelper extends HttpHelper {
File file = new File(serverFilePath);
//设置文件输出类型
response.setContentType("application/octet-stream");
/**文件下载图片乱码处理**/
String fileName = URLEncoder.encode(saveFileName, "UTF-8");
// 设置下载的文件名
response.setHeader("Content-disposition", "attachment; filename=" + new String(saveFileName.getBytes("utf-8"), "UTF-8"));
// 2.其他浏览器attachment;filename*=utf-8'zh_cn
response.setHeader("Content-Disposition", "attachment; filename*=utf-8'zh_cn'" + fileName);
//设置输出长度
response.setHeader("Content-Length", String.valueOf(file.length()));
ServletOutputStream bos = response.getOutputStream();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment