Jsf Primefaces文件下载组件不工作

Jsf Primefaces文件下载组件不工作,jsf,primefaces,Jsf,Primefaces,在Primefaces 5.1中,我使用fileDownload组件从tomcat webapps文件夹下载xls,但文件下载不起作用 user.xhtml <p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false"> <p:graphicImage name="/demo/images/ajaxl

在Primefaces 5.1中,我使用fileDownload组件从tomcat webapps文件夹下载xls,但文件下载不起作用

user.xhtml

<p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false">
    <p:graphicImage name="/demo/images/ajaxloadingbar.gif" />
</p:dialog>

<h:form>
    <p:commandButton value="Download" ajax="false" action="#{user.FileDownloadView}" onclick="PrimeFaces.monitorDownload(start, stop);" icon="ui-icon-arrowthick-1-s">
        <p:fileDownload value="#{user.file}" />
    </p:commandButton>
</h:form>
<script type="text/javascript">
function start() {
    PF('statusDialog').show();
}

function stop() {
    PF('statusDialog').hide();
}
</script>
}


当我单击commandButton时,状态对话框打开和隐藏,但不显示下载选项。我检查日志文件该文件存在于我的webapps文件夹中,但文件未下载。我更改命令按钮操作以替换actionListener,但也不起作用

了解如何使用
@PostConstruct
而不是使用您的构造函数或更改来尝试它,但它不起作用
private StreamedContent file;
public void FileDownloadView() 
{        

InputStream stream =((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream(".../webapps/project/root/user.xls");
        file = new DefaultStreamedContent(stream, "application/xls", "user.xls");