primeFaces : fileUpload to byte[]

前端 未结 1 1892
一向
一向 2021-01-14 02:09

I am trying to get the uploaded image of as byte[] and persist it in DB by JPA. But I\'m facing a problem and I\'m not even su

相关标签:
1条回答
  • 2021-01-14 02:56

    You forgot to read the PrimeFaces User Guide. Here's an extract of <p:fileUpload> chapter:

    Getting started with FileUpload

    First thing to do is to configure the fileupload filter which parses the multipart request. FileUpload filter should map to Faces Servlet.

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

    Without that filter, no one action method inside a <h:form enctype="multipart/form-data"> can be invoked nor will the submitted data be properly parsed.

    As to the warning that the method cannot be found, this is related to the IDE which you're using which is pretending to be smarter than it is. Disable EL validation in that IDE to avoid those confusing warnings and look if you can't upgrade the IDE.

    0 讨论(0)
提交回复
热议问题