如何解决当某些功能在我的Web Java Spring MVC中运行时,如何实现进度栏
它提供的服务之一是,当用户单击按钮时,服务器上将发生长时间运行的过程。 (查询数据库,写入文件,写入日志等),此过程可能需要几秒钟或几分钟。 问题 **我如何实现服务以更新客户端的进度。
@PostMapping(值=“ /转换”,产生= {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody 公共ZawGyi2UnicodeJsonRespone转换(@ModelAttribute @Valid ZawGyi2Unicode zg2un,BindingResult结果) 引发IOException,ParseException {
ZawGyi2UnicodeJsonRespone respone = new ZawGyi2UnicodeJsonRespone();
....
data.put(“-”, 新的Object [] {data0,data1,data2,data3,data4,data5,data6,data7,data8,data9,data10,data11, 数据12,数据13,数据14,数据15,数据16,数据17,数据18,数据19,数据20,数据21,数据22, data23,data24,data25,data26,data27,data28,data29,data30,cell31});
// Iterate over data and write to sheet
Set<String> keyset = data.keySet();
for (String key : keyset) {
row = sheet.createRow(rownum++);
Object[] objArr = data.get(key);
int cellnum = 0;
for (Object obj : objArr) {
Cell cell = row.createCell(cellnum++);
cell.getStringCellValue().getBytes(Charset.forName("UTF-8"));
if (obj instanceof String) {
cell.setCellValue((String) obj);
} else if (obj instanceof Date) {
cell.setCellValue((Date) obj);
} else if (obj instanceof Integer) {
cell.setCellValue((Integer) obj);
}
}
}
} try {
//get befor "."
String filename = filePath;
int iend = filename.indexOf(".");
String subString="";
if (iend != -1) {
subString = filename.substring(0,iend);
}
outPutPath = subString+"Output.xlsx";
// Write the workbook in file system
FileOutputStream out = new FileOutputStream(new File(FILE_PATH+outPutPath));
//FileOutputStream out = new FileOutputStream(new File(outPutPath));
workbook.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
respone.setValidated(true);
respone.setZg2un(zg2un);
}
return respone;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。