primefaces 3.5 uploadfile无法正常工作,我使用的是NetBean 7.2.1 [英] primefaces 3.5 uploadfile not working, i using netbean 7.2.1

查看:95
本文介绍了primefaces 3.5 uploadfile无法正常工作,我使用的是NetBean 7.2.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题出在primefaces的文件上传器上 web.xml

the problem is with file uploader from primefaces 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>

.xhtml

            </h:form>
               ...
            </h:form>
            <h:form enctype="multipart/form-data">
                <p:fileUpload value="#{contratosMB.fileContrato}" mode="simple"/>

                <p:commandButton value="Submit" ajax="false"  
                                 actionListener="#{contratosMB.upload}" update=":form2:formgen:growl"/>
            </h:form>

contratosMB.java

contratosMB.java

 public void upload() {  
        if(fileContrato != null) {  
            JsfUtil.addSuccessMessage("Se ha cargado correctamente el archivo: " + fileContrato.getFileName()); 
        }  
    }  

我读到这样的问题,但没有任何帮助. 我在项目中添加了commons-fileupload和commons-io, 但是不工作,不要进入上载方法,不要发送异常.

I was read some question like this, but nothing was help me... i was add commons-fileupload and commons-io to the project, but dont work not go inside upload method, dont send exception.

推荐答案

它可以创建和编辑face-config:

it working creating and editing faces-config:

    <dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId> commons-fileupload</artifactId>
    <version>1.2.1</version>
</dependency>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId> commons-io</artifactId>
    <version>1.4</version>
</dependency>

但是对我来说不完整,因为表单上载器位于其他表单中...

but dont work full for me because form uploader is inside to other form...

   <h:form>
  ...
        <h:form enctype="multipart/form-data">  

            <p:messages showDetail="true"/>  

            <p:fileUpload value="#{contratosMB.fileContrato}" mode="simple"/>  

            <p:commandButton value="Submit" ajax="false"  
                             actionListener="#{contratosMB.upload}"/>  

        </h:form>  
    </h:form>

任何人都可以告诉我为什么吗?

any body can tell me why??

这篇关于primefaces 3.5 uploadfile无法正常工作,我使用的是NetBean 7.2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆