PrimeFaces fileDownload does not work

后端 未结 4 1290
深忆病人
深忆病人 2021-01-02 18:03

I can\'t get the primeFaces work. While I succeed in downloading the file using a custom download bean. Seems like the issu is related to the

4条回答
  •  一生所求
    2021-01-02 18:14

    My fileuplaad.xhtml is as shown below

      
    
    
        
                
                                                    
                                                
    
    
            
        
    
    Here is my bean:
    @ManagedBean(name="fileDownloadController")
    public class FileDownloadController implements Serializable {
    
    
        private static final long serialVersionUID = 1L;
    
        private StreamedContent file;  
    
    
        public FileDownloadController() {          
            InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/download/FileName.csv");  
            file = new DefaultStreamedContent(stream, "download/csv", "FileName.csv");  
        }  
    
        public StreamedContent getFile() {  
            return file;  
        }    
    }
    

提交回复
热议问题