primefaces handleFileUpload不会触发

时间:2012-08-14 11:04:12

标签: file-upload primefaces

我正在尝试使用primefaces fileUpload实现一个页面但是我的handleUpload函数没有被触发。 我的xhtml:

<h:form enctype="multipart/form-data">
  <p:panel id="uploadFormPanel" header="File upload">
     <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">  
         <h:outputText value="#{criteriaTranslation.questionaireFile}:" />
         <p:fileUpload update="uploadMessages"   
                       fileUploadListener="#{critereCSVImporter.handleFileUpload}"
                       mode="advanced"
                       allowTypes="/(\.|\/)(csv)$/"/>  
    </h:panelGrid>
    <p:growl id="uploadMessages" showDetail="true"/>
  </p:panel>
</h:form> 

我的支持bean:

@ManagedBean
@ViewScoped
public class CritereCSVImporter {

@Inject
private CriteriaBL criteriaBL;
private String OCRMODE;

public void handleFileUpload(FileUploadEvent event) {
    System.out.println("handle");
    InputStream inputStream = event.getFile().getInputstream();
}

我的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>

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

将commons-fileupload和commons-io jar放在你的lib文件夹中

Apache Commons FileUpload

Apache Commons IO