Commit 5a3916c3 authored by yanzg's avatar yanzg

接口文档的支持

parent ef029db4
...@@ -5,9 +5,11 @@ import com.yanzuoguang.util.helper.HttpHelper; ...@@ -5,9 +5,11 @@ import com.yanzuoguang.util.helper.HttpHelper;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.URLEncoder;
/** /**
* HTTP文件 * HTTP文件
*
* @author 颜佐光 * @author 颜佐光
*/ */
public class HttpFileHelper extends HttpHelper { public class HttpFileHelper extends HttpHelper {
...@@ -25,8 +27,12 @@ public class HttpFileHelper extends HttpHelper { ...@@ -25,8 +27,12 @@ public class HttpFileHelper extends HttpHelper {
File file = new File(serverFilePath); File file = new File(serverFilePath);
//设置文件输出类型 //设置文件输出类型
response.setContentType("application/octet-stream"); 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())); response.setHeader("Content-Length", String.valueOf(file.length()));
ServletOutputStream bos = response.getOutputStream(); 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