primefaces 的下载功能,p:fileDownload的用法

前端页面
emptyMessage="" paginator="true" rows="10" paginatorPosition="top">












后台代码
public class TreeBean{
private List files;
private StreamedContent downLoadFile;//下载要用
public List getFiles() {
return files;
}
public void setFiles(List files) {
this.files = files;
}
public StreamedContent getDownLoadFile() {
return downLoadFile;
}
public void setDownLoadFile(StreamedContent downLoadFile) {
this.downLoadFile = downLoadFile;
}
//取得files的代码(省略)

}

//封装展现的对象
public class PatchOutFile implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2666220076595535241L;

private String file;
private String path;
private StreamedContent downFile;
public PatchOutFile(){};
public PatchOutFile(String file,String path){
this.file = file;
this.path = path;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public StreamedContent getDownLoadFile() {
try {
InputStream stream = new FileInputStream(selectFile.getPath());

downLoadFile = new DefaultStreamedContent(stream, "DOS/PC - Pkzipped archive", selectFile.getFile());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return downLoadFile;
}
public void setDownFile(StreamedContent downFile) {
this.downFile = downFile;
}


}

你可能感兴趣的:(primefaces 的下载功能,p:fileDownload的用法)