简体   繁体   English

primefaces文件上传不起作用

[英]primefaces file upload not working

I have the following code, running on jboss eap 6.1: 我有以下代码,在jboss eap 6.1上运行:

 <h:form id="SatelliteListForm" enctype="multipart/form-data">
...
<p:fileUpload id="datamodelImport" mode="advanced" auto="true" disabled="#{empty satelliteController.selected}" fileUploadListener="#{satelliteController.importDatamodel}" update=":messages" allowTypes="/(\.|\/)(csv)$/"/> 

web.xml contains this: web.xml包含以下内容:

   <filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>

pom.xml have this: pom.xml具有以下功能:

<dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>4.0</version>
    </dependency>
<dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3</version>
    </dependency>

the problem? 问题? it doesn't not work. 这是行不通的。 The UI seems to be working fine, but the file upload listener is not called. 用户界面似乎运行良好,但未调用文件上传侦听器。 Using search BalucC suggest to debug http communication. 使用搜索BalucC建议调试http通信。 Done, it is not the browser fault. 完成,这不是浏览器故障。 Then he suggest to debug the decode method of the corresponding primefaces class. 然后,他建议调试相应的primefaces类的解码方法。 Done. 做完了 In the following class org.primefaces.component.fileupload.CommonsFileUploadDecoder he do this check: if(multipartRequest != null) // keep going, otherwise stop 在下面的类org.primefaces.component.fileupload.C​​ommonsFileUploadDecoder中,他执行以下检查:if(multipartRequest!= null)//继续进行,否则停止

in my case that variable is null. 就我而言,该变量为null。 I can't understand why. 我不明白为什么。 The generated html code correctly contains the enctype. 生成的html代码正确包含enctype。

BalusC suggest that something could happen during request processing. BalusC建议在请求处理期间可能会发生某些事情。 I'm using atmosphere, but it uses another servlet to communicate. 我正在使用大气,但是它使用另一个servlet进行通信。 Also he is complaining for quite some time about comet support (someday I will fix that). 此外,他还抱怨彗星支持了一段时间(有一天我会解决)。 Don't know if it matters. 不知道这是否重要。

What else can I check? 我还能检查什么? It's irritating that something so simple as file upload is wasting so much of my time... 令人讨厌的是,像文件上传这样简单的事情浪费了我很多时间……

Thank you for your time. 感谢您的时间。

did you try to add the following parameter to your web.xml? 您是否尝试将以下参数添加到web.xml?

<context-param>
    <param-name>primefaces.UPLOADER</param-name>
    <param-value>commons</param-value>
</context-param>

I had the same behaviour until I added these context param 在添加这些上下文参数之前,我具有相同的行为

Regards 问候

Michael 麦可

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM