Amazon Ads

2008年6月5日 星期四

在JSF中下載檔案.csv

FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces
.getExternalContext().getResponse();
response.setContentType("application/csv");
response.setContentLength(data.length);
response.setHeader("Content-disposition", "inline; filename=\""
+ filename + "\"");
try {
ServletOutputStream out = response.getOutputStream();
out.write(data);
} catch (IOException ex) {

}

faces.responseComplete();

沒有留言: