开发者

Spring Webflow Application + Primefaces, Fileupload does not work, HTTP Error or/and IO Error

开发者 https://www.devze.com 2023-01-30 17:17 出处:网络
we are developing a JSF spring webflow web application and we are trying to use the primefaces fileupload widget. primefaces works fine, the widgets get rendered correctly. however the fileupload is n

we are developing a JSF spring webflow web application and we are trying to use the primefaces fileupload widget. primefaces works fine, the widgets get rendered correctly. however the fileupload is not working. the handlefileupload function in the backingbean FileUploadController is never called. other primefaces components for example a button can call functions in that bean, so it gets initialized correct开发者_如何学JAVAly. below you find our configuration. currently we are developing in eclipse and deploying the web app with maven and run the app with a jetty server directly in eclipse. deploying the .war on tomcat didnt work either.

Problem:

  • after file selection and clicking on upload the widget is giving either the error 'IO Error' or 'HTTP Error'
  • some data is transfered to the server (we sniffed the network traffic)
  • handlefileupload() function in the backingbean FileUploadController is never called

Dependencies

  • 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 and 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);  
 }

beans-config.xml

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

Thanks in advance. We hope someone can help us :)


use this filter instead

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


There is and error or you have copied it wrong from your's xhtml file

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

The "{" is missing before "fileUploadController.handleFileUpload}" should be:

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

精彩评论

暂无评论...
验证码 换一张
取 消