我正在尝试从xhtml页面调用我的Controller代码。我的代码就是这样上传一个excel文件。但是,这段代码没有击中Controller。任何人都可以帮我解决这个问题吗?
<h:form name="addBulkTnForm" id="addBulkTnFormId" enctype="multipart/form-data">
<h:panelGroup id="fileUploadPnGrp">
<p:fileUpload mode="simple" value="#{controller.addTnBulkFile}">
</p:fileUpload>
<p:commandButton value="Upload" listener="#{controller.addBulkTnUpload}" ajax="false"></p:commandButton>
</h:panelGroup>
</h:form>
以下是我的依赖
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.10</version>
</dependency>
答案 0 :(得分:0)
您是否从web.xml配置了primefaces上传过滤器?
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>auto|native|commons</param-value> <!-- One of these -->
</context-param>
<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>
您可以查看https://www.primefaces.org/docs/guide/primefaces_user_guide_5_2.pdf