日期:2014-05-18  浏览次数:20862 次

primefaces 中的 fileupload错误
我刚开始学习primefaces,不过在联系文件上传的时候出现了问题,在我的工程中我添加了primefaces-2.2.1.jar,我在网上查找准备解决问题的时候看到有一个人的发帖是他也遇到差不多的问题,他工程中有commons-fileUpload.
1、我想问一下这个是不是必须的?
2、我在primefaces的文档中看到介绍,开始FileUpload中在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>
  不过我在web.xml中添加这段就会报错: "......\nbproject\build-impl.xml:690: 尚未部署该模块。"请问一下怎么解决?

我的web.xml:
 
XML code

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

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

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>



3、index.xhtml:
 
HTML code

      <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <h:form id="fileUploadForm" enctype="multipart/form-data">
            <p:growl id="message" showDetail="true"/>
            <p:fileUpload id="fileUPloadComm" allowTypes="*.jpg" description="*.jpg" update="message"
                          fileUploadListener="#{testBean.fileUploadController}"/>
        </h:form>
    </h:body>
</html>
    


好像在其中fileUploadListener根本没有执行。

希望各位帮帮忙啊……

------解决方案--------------------