Jsf 文件下载未工作,且未执行任何操作

Jsf 文件下载未工作,且未执行任何操作,jsf,primefaces,download,Jsf,Primefaces,Download,单击下载按钮时,actionListener在使用ajax=“false”状态但不使用ajax=“false”的情况下不工作,actionListener工作但不下载文件 <html xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:h="http://java.sun.c

单击下载按钮时,actionListener在使用ajax=“false”状态但不使用ajax=“false”的情况下不工作,actionListener工作但不下载文件

<html xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tsc="http://java.sun.com/jsf/composite">

<h:form>
<p:commandButton immediate="true" value="#{msgs.common_click_download}"
    icon="ui-icon-arrowthick-1-s" process="@this"
    rendered="#{manehHelperMB.isFileExist('/home/hazemelshenawy/111.txt')}">
    <p:fileDownload process="@this" contentDisposition="inline"
        value="#{fileDownloaderMB.downloadFile('/home/hazemelshenawy/111.txt')}" />
</p:commandButton>

 </h:form>
  </html>

与p:fileDownload一起使用时,p:commandButton中不需要ActionListener属性,但您应该具有中所述的
ajax=“false”

请尝试正确设置文件路径。 例如:;在.xhtml文件中

rendered="#{manehHelperMB.isFileExist('D:\\home\\hazemelshenawy\\111.txt')}">
value="#{fileDownloaderMB.downloadFile('D:\\home\\hazemelshenawy\\111.txt')}"
在java类中

File fi = new File("D:\\home\\hazemelshenawy\\111.txt");
此外,还应具有setter和getter方法:

public DefaultStreamedContent getFile() {
        return file;
    }
public void setFile(DefaultStreamedContent file) {
        this.file = file;
    }

与p:fileDownload一起使用时,p:commandButton中不需要ActionListener属性,但您应该具有中所述的
ajax=“false”

请尝试正确设置文件路径。 例如:;在.xhtml文件中

rendered="#{manehHelperMB.isFileExist('D:\\home\\hazemelshenawy\\111.txt')}">
value="#{fileDownloaderMB.downloadFile('D:\\home\\hazemelshenawy\\111.txt')}"
在java类中

File fi = new File("D:\\home\\hazemelshenawy\\111.txt");
此外,还应具有setter和getter方法:

public DefaultStreamedContent getFile() {
        return file;
    }
public void setFile(DefaultStreamedContent file) {
        this.file = file;
    }

你用哪个容器?雄猫?服务器日志中没有任何错误吗?默认情况下,Tomcat不支持在el表达式中传递参数,除非您确保已正确设置“el-impl-2.2.jar”或更高版本。Tomcat 8,是的,我在服务器日志中没有任何错误您使用的容器是什么?雄猫?服务器日志中没有任何错误吗?默认情况下,Tomcat不支持在el表达式中传递参数,除非您确保已正确设置“el-impl-2.2.jar”或更高版本。Tomcat 8,是的,我在服务器日志中没有任何错误