GWT Download
GWT下载导入的模板
final FormPanel download = new FormPanel(); download.setAction(GWT.getHostPageBaseURL() + "download"); download.setMethod(FormPanel.METHOD_POST); Button dl = new Button("Download"); dl.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { download.submit(); } });
servlet:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("file download"); String fileName = "ProductImportTemplate.xls"; response.setContentType("application/force-download;charset=UTF-8"); response.addHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\""); // PrintWriter pw = new PrintWriter(response.getOutputStream()); // pw.write("test....."); // pw.flush(); // pw.close(); // String path = request.getContextPath()+"/downloads/ProductImportTemplate.xls"; // System.out.println("path: " + path); // response.sendRedirect(path); }
相关推荐
89384099 2012-08-22
84487906 2011-10-13
orangesdk 2012-01-12
84487906 2012-01-12
JimmyblyLee 2012-01-12
89384099 2012-01-12
shangsoft 2012-01-12
84487906 2014-08-17
JimmyblyLee 2016-08-10
84487906 2012-01-12
shangsoft 2011-10-22
orangesdk 2011-03-23
XuDTone 2011-03-22
JimmyblyLee 2011-01-07
heimeiyingwang 2010-08-12
84487906 2010-08-12