我尝试使用 GWT-RPC 调用 servlet 来导出数据,为了简化案例,我只是尝试先对输出文本进行硬编码,在 RemoteServiceServlet 中使用以下代码
public void exportHistory(ArrayList<String> sqlHistory){
this.sqlHistory = sqlHistory;
try {
HttpServletResponse res = this.getThreadLocalResponse();
res.setContentType("text/plain");
res.setHeader("Content-disposition", "attachment; filename=history.txt");
ServletOutputStream out = res.getOutputStream();
out.println("test1");
out.println("test2");
out.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
但是它在asyncCallback中返回onFailure(Throwable catch),捕获的是InvocationException。问题是什么?