在gwt中,如何导出ArrayList<;字符串>;并提示保存对话框供用户下载?
我尝试使用GWT-RPC调用servlet来导出数据,为了简化这种情况,我只是尝试首先硬编码输出文本,在RemoteServiceServlet中使用以下代码在gwt中,如何导出ArrayList<;字符串>;并提示保存对话框供用户下载?,gwt,servlets,export,Gwt,Servlets,Export,我尝试使用GWT-RPC调用servlet来导出数据,为了简化这种情况,我只是尝试首先硬编码输出文本,在RemoteServiceServlet中使用以下代码 public void exportHistory(ArrayList<String> sqlHistory){ this.sqlHistory = sqlHistory; try { HttpServletResponse res = this.getThreadLocalResponse()
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();
}
}
public void exportHistory(ArrayList sqlHistory){
this.sqlHistory=sqlHistory;
试一试{
HttpServletResponse res=this.getThreadLocalResponse();
res.setContentType(“文本/普通”);
res.setHeader(“内容处置”、“附件;文件名=history.txt”);
ServletOutputStream out=res.getOutputStream();
out.println(“test1”);
out.println(“test2”);
out.flush();
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
但是它在异步回调中返回onFailure(Throwable-catch),捕获的是调用异常。
有什么问题吗?尝试使用
json
对象传递列表