文件未下载

File not downloading

我在尝试使用我的程序时遇到困难 <p:fileDownload/> 我按下按钮触发它。

 <p:commandButton>
    <p:fileDownload value="#{searchBean.currentSearch.file}"/>
 </p:commandButton>

我的下载代码

public StreamedContent getFile() throws FileNotFoundException
{
    InputStream stream =  new FileInputStream(new File(ppath + ".csv"));
    StreamedContent temp = new DefaultStreamedContent(stream, "download/csv", ppath + ".csv");
    return temp;
}

我已经在调试模式下检查过流不为空并且文件确实存在。我正在使用 glassfish 3.1 进行托管。我哪里出错了?

尝试将 ajax 设置为 false。

 <p:commandButton ajax="false">
    <p:fileDownload value="#{searchBean.currentSearch.file}"/>
 </p:commandButton>