Spring Webflow Application + Primefaces,Fileupload不起作用,HTTP错误或/和IO错误

时间:2010-12-14 11:32:19

标签: file-upload primefaces spring-webflow ioerror

我们正在开发 JSF spring webflow Web应用程序,我们正在尝试使用 primefaces fileupload 小部件。 primefaces工作正常,小部件正确呈现。但是文件上载不起作用。从不调用backingbean FileUploadController中的handlefileupload函数。其他primefaces组件,例如按钮可以调用该bean中的函数,因此它可以正确初始化。下面你找到我们的配置。目前我们正在eclipse中开发并使用maven部署Web应用程序并直接在eclipse中使用jetty服务器运行应用程序。在tomcat上部署.war也没有用。

问题:

  • 选择文件并单击上传后,窗口小部件会显示错误“IO错误”或“HTTP错误”
  • 一些数据被转移到服务器(我们嗅探网络流量)
  • 从不调用backbean FileUploadController中的
  • handlefileupload()函数

依赖

  • org.primefaces 2.2.RC2
  • org.springframework.webflow,webflow and faces 2.2.1.RELEASE
  • commons-fileupload 1.2.2
  • commons-io 2.0
  • com.sun.faces,api和impl 2.0.3
  • org.springframework.security

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

start.xhtml

      <h:form id="mainForm" enctype="multipart/form-data" prependid="false" > 
       <p:fileUpload id="fileUp" fileUploadListener="#fileUploadController.handleFileUpload}"   
    description="Images" /></h:form> 

FileUploadController.java

 public void handleFileUpload(FileUploadEvent event) {  
  System.out.println("FileUpload Test");

     FacesMessage msg = new FacesMessage("ok", event.getFile().getFileName() + " is uploaded.");  
     FacesContext.getCurrentInstance().addMessage(null, msg);  
 }

豆-config.xml中

<bean id="fileUploadController" class="de.hsrm.mi.media.FileUploadController" scope="session"></bean>

提前致谢。我们希望有人可以帮助我们:)

2 个答案:

答案 0 :(得分:2)

使用此过滤器

<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>Spring MVC Dispatcher Servlet</servlet-name>
</filter-mapping>

答案 1 :(得分:0)

存在错误,或者您从xhtml文件中将其复制错误

<h:form id="mainForm" enctype="multipart/form-data" prependid="false" > 
       <p:fileUpload id="fileUp" fileUploadListener="#fileUploadController.handleFileUpload}"   
    description="Images" /></h:form>

“fileUploadController.handleFileUpload}”之前缺少“{”:

<h:form id="mainForm" enctype="multipart/form-data" prependid="false" > 
       <p:fileUpload id="fileUp" fileUploadListener="#{fileUploadController.handleFileUpload}"   
    description="Images" /></h:form>