Java 文件上传?侦听器方法从未被调用

Java 文件上传?侦听器方法从未被调用,java,file,jsf,primefaces,glassfish,Java,File,Jsf,Primefaces,Glassfish,我正在尝试实现一个文件上传程序。我正在使用Java7、PrimeFaces4和glassfish 3.1.2 我试着按照这个职位的公认答案中的指示去做 没有成功。 这是我的web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc

我正在尝试实现一个文件上传程序。我正在使用Java7、PrimeFaces4和glassfish 3.1.2 我试着按照这个职位的公认答案中的指示去做 没有成功。 这是我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     version="3.0">

          <!-- Spring Context Configuration' s Path definition -->
          <context-param>
         <param-name>contextConfigLocation</param-name>
         <param-value>
            /WEB-INF/applicationContext.xml
         </param-value>
      </context-param>

      <!-- The Bootstrap listener to start up and shut down Spring's root WebApplicationContext. It is registered to Servlet Container -->
      <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
      </listener>
      <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
      </listener>

     <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <!-- JSF Servlet is defined to container -->

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Mapping with servlet and url for the http requests. -->
     <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
   </servlet-mapping>

   <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.xhtml</url-pattern>
   </servlet-mapping>

     <welcome-file-list>  
        <welcome-file>index.html</welcome-file>  
     </welcome-file-list>  

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>

    <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>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>          
</web-app>
问题是我的方法从未被调用。我在表单中添加了加密,并在
web.xml
中添加了过滤器,但没有成功。 我做错了什么????
提前谢谢。

你在做什么加密?我没有加密任何东西,但如果你是指我正在使用的百科全书:为了让上传过程正常工作,你必须将commons-fileupload.jar、commons-io-.jar添加到你的web inf/lib folderI与maven合作,所以我在我的pom中添加了它们,然后我构建了它们,因为如果我没有;如果你不编译,它就不会工作。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<h:body>
    <ui:composition template="../template/Layout.xhtml">
        <ui:define name="content">
            <div class="frame">
                <h:form id="originadorForm" enctype="multipart/form-data">
                    <p:growl id="growl" showDetail="true" life="3000" />
                    <p:fileUpload label="Cargar Imagen" fileUploadListener="#{originadorMB.handleFileUpload}" mode="advanced" update="growl" auto="true" sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>                    
                </h:form>
            </div>
        </ui:define>
    </ui:composition>
</h:body>
</html>
public void handleFileUpload(FileUploadEvent event) {
    FacesMessage msg = new FacesMessage("Exito", event.getFile().getFileName() + " fue subido. " + selectedOriginadoresListDTO.getImagen());
    System.out.println(">>>>>>>>>>>>>" + selectedOriginadoresListDTO.getImagen() + " && " + event.getFile().getFileName());
FacesContext.getCurrentInstance().addMessage(null, msg);
}