我试图从本质上是一个“.csv”文件的 servlet 中获取响应。我将文件上传到服务器解析它读取它,然后如果文件中有任何错误,我将其写入 CSV 文件并将其发送回作为响应。但似乎响应永远不会回到 onSubmitComplete。这是我的代码。
if (!errorContents.isEmpty()) {
CSVWriter csv = null;
try{
String filename = "errorList.csv";
resp.setContentType("text/plain");
resp.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
csv = new CSVWriter(new OutputStreamWriter(resp.getOutputStream()));
for (String[] row : errorContents) {
csv.writeNext(row);
}
}finally {
csv.close();
}
} else {
resp.setContentType("text/plain");
resp.getWriter().write("Successful Processing");
}
现在客户端控制器的代码
formPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
@Override
public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
controller.reloadAll();
com.google.gwt.user.client.Window.alert(event.getResults().toString());
hideContentDiv();
// loading.hide();
}