2017-11-29 11 views
0

まず、私が使用している技術Primefaces 6.1,PrettyFaces 3.3.3およびWildfly 11を使用しています。私は、Primeface <p:fileUpload>コンポーネントを使用してデータベースにファイルをアップロードするだけです。ここで私が使用したコードスニペットがあります。Primeface File Upload PrettyFacesを追加した後に動作しなくなりました

<h:form> 
    <p:fileUpload fileUploadListener="#{imageopbean.uploadImage}" mode="advanced" auto="true" style="display:none;" oncomplete="uppicture()" styleClass="imageUploadButton" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" > 
      <f:attribute name="uniqueid" value="#{profileBean.theUser.userId}"/> 
    </p:fileUpload> 
</h:form> 

PrettyFacesライブラリを使用する前に動作していました。今、それはfileUploadListenerを呼び出さない。私はthis質問といくつかの他の解決策を読んだ。しかし、私はそれらを働かせることはできません。私は間違って何をしていますか?ここに私のコードの他の部分があります。ありがとう。

web.xmlの

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"> 
    <context-param> 
     <param-name>javax.faces.PROJECT_STAGE</param-name> 
     <param-value>Development</param-value> 
    </context-param> 

    <context-param> 
     <param-name>primefaces.FONT_AWESOME</param-name> 
     <param-value>true</param-value> 
    </context-param> 

    <context-param> 
     <param-name>primefaces.THEME</param-name> 
     <param-value>extranet</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_BUFFER_SIZE</param-name> 
     <param-value>2048576</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.STATE_SAVING_METHOD</param-name> 
     <param-value>server</param-value> 
    </context-param> 

    <context-param> 
     <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> 
     <param-value>2</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>*.xhtml</url-pattern> 
    </servlet-mapping> 

    <filter> 
     <filter-name>primeFacesFileUploadFilter</filter-name> 
     <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class> 
    </filter> 
    <filter-mapping> 
     <filter-name>primeFacesFileUploadFilter</filter-name> 
     <servlet-name>facesServlet</servlet-name> 
     <dispatcher>REQUEST</dispatcher> 
     <dispatcher>FORWARD</dispatcher> 
    </filter-mapping> 

    <filter-mapping> 
     <filter-name>loginFilter</filter-name> 
     <url-pattern /> 
    </filter-mapping> 

    <filter> 
     <filter-name>Pretty Filter</filter-name> 
     <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class> 
    </filter> 

    <filter-mapping> 
     <filter-name>Pretty Filter</filter-name> 
     <url-pattern>/*</url-pattern> 
     <dispatcher>FORWARD</dispatcher> 
     <dispatcher>REQUEST</dispatcher> 
     <dispatcher>ERROR</dispatcher> 
     <dispatcher>ASYNC</dispatcher> 
    </filter-mapping> 

    <context-param> 
     <param-name>primefaces.UPLOADER</param-name> 
     <param-value>commons</param-value> 
    </context-param> 

    <session-config> 
     <session-timeout> 
      60 
     </session-timeout> 
    </session-config> 

    <welcome-file-list> 
     <welcome-file>login.xhtml</welcome-file> 
    </welcome-file-list>  

    <error-page> 
     <error-code>404</error-code> 
     <location>/error-404.xhtml</location> 
    </error-page> 
    <error-page> 
     <exception-type>javax.faces.application.ViewExpiredException</exception-type> 
     <location>/login</location> 
    </error-page> 
    <error-page> 
     <error-code>500</error-code> 
     <location>/login</location> 
    </error-page> 
</web-app> 

ImageBean.java

@Named("imageopbean") 
@RequestScoped 
public class ImageBean implements Serializable { 

    @EJB 
    private ImageManager imageManager; 

    /** 
    * 
    * @param event 
    */ 
    public void uploadImage(FileUploadEvent event) { 
     System.out.println("UPLOAD WORK"); 
     .... 
    } 
} 
+0

あなたが ':ここ は再び解決策があります自動的に 'PrettyFacesフィルタが追加されている(瓶を追加することによって)、明示的な注文を追加する必要があるかもしれません(注文**は**関連性の高い記事です。 ') – Kukeltje

+0

私は、複製の#1に少しコメントを追加しました。それはあなたを助けますか? – Kukeltje

+0

注釈付きのWebフィルタを使用しているため、Webフィルタがアップロード要求を消費する可能性があります。 – mismanc

答えて

0

私は、web.xmlにフィルタの組み合わせのほとんどを試してみましたが、何も働いていません。 私は

、これを発見したと私は私がweb.xmlpom.xmlに挿入されたすべてのものを削除しました。

1 - あなたのJSFページ

<script type="text/javascript"> 
    $(document).ready(function() { 
     $("form[enctype='multipart/form-data']").attr("action","#{request.contextPath}/test/fileupload.xhtml"); 
    }); 
</script> 

ザッツすべてに応じてご<h:fom>タグ

2 - 編集スクリプトにenctype="multipart/form-data"を追加します。..

関連する問題