//下载任务
public String synchronyTask()throws Exception{
HttpServletResponse response = super.getHttpResponse();
try {
response.setContentType("text/html;charset=UTF-8");
byte output[];
JSONObject branchObject=offRegionService.synchronyTask();
response.setContentType("application/octet-stream");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition", "inline; filename=\""
+ URLEncoder.encode("data", "UTF-8") + ".json\"");
output = branchObject.toString().getBytes();
HttpServletResponse res = response;
OutputStream os = res.getOutputStream();
os.write(output);
os.close();
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
java 文件下载
最新推荐文章于 2023-07-26 16:45:09 发布