解决火狐浏览器文件名空格出现+号
This commit is contained in:
@@ -1395,7 +1395,7 @@ public class ExportExcel {
|
||||
public ExportExcel write(HttpServletResponse response, String fileName) throws IOException{
|
||||
response.reset();
|
||||
response.setContentType("application/octet-stream; charset=utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename="+Encodes.urlEncode(fileName));
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
|
||||
write(response.getOutputStream());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.nis.web.controller;
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -2237,6 +2238,11 @@ public class BaseController {
|
||||
map.put("labels", labels);
|
||||
|
||||
String fileName = msgProp.getProperty(functionName, functionName)+"_"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
||||
if(request.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
}else{
|
||||
fileName = new String(fileName.getBytes("UTF-8"),"ISO8859-1");
|
||||
}
|
||||
new ExportExcel(msgProp,titleList,noExportMap,classMap,1).setDataList(msgProp,dataMap,map).write(response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user