Spring Webflow 应用程序Primefaces、文件上传不起作用、HTTP 错误或/和 IO 错误
我们正在开发一个JSF spring webflow Web应用程序,并且我们正在尝试使用primefaces fileupload小部件。 primefaces 工作正常,小部件可以正确渲染。但是文件上传不起作用。 backingbean FileUploadController 中的handlefileupload 函数永远不会被调用。其他 primefaces 组件(例如按钮)可以调用该 bean 中的函数,因此它可以正确初始化。下面您可以找到我们的配置。目前我们正在 Eclipse 中开发并使用 Maven 部署 Web 应用程序,并直接在 Eclipse 中使用 jetty 服务器运行该应用程序。在 tomcat 上部署 .war 也不起作用。
问题:
- 选择文件并单击上传后,小部件给出错误“IO 错误”或“HTTP 错误”,
- 一些数据传输到服务器(我们嗅探网络流量)
- backingbean FileUploadController 中的handlefileupload() 函数永远不会被调用
依赖项
- org.primefaces 2.2.RC2
- org.springframework.webflow、webflow 和 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);
}
beans-config.xml
<bean id="fileUploadController" class="de.hsrm.mi.media.FileUploadController" scope="session"></bean>
提前致谢。我们希望有人可以帮助我们:)
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 correctly. 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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这个过滤器代替
use this filter instead
存在错误,或者您从 xhtml 文件中复制了错误的内容
“fileUploadController.handleFileUpload}”之前缺少“{”应该是:
There is and error or you have copied it wrong from your's xhtml file
The "{" is missing before "fileUploadController.handleFileUpload}" should be: