Spring Webflow 应用程序Primefaces、文件上传不起作用、HTTP 错误或/和 IO 错误

发布于 2024-10-07 20:37:21 字数 2008 浏览 0 评论 0原文

我们正在开发一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡写薰衣草的香 2024-10-14 20:37:21

使用这个过滤器代替

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

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>
旧夏天 2024-10-14 20:37:21

存在错误,或者您从 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文