获取primefaces号码:文件上传到谷歌下工作的AppEngine [英] Getting primefaces p:fileUpload to work under google appengine

查看:199
本文介绍了获取primefaces号码:文件上传到谷歌下工作的AppEngine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过,有可能获得primefaces文件上传与谷歌AppEngine上工作了一些调整。它需要Apache文件上传,共同IO,所以我加了公地文件上传-1.2.2.jar和commons-IO-1.3.2.jar到我的WEB-INF / lib文件夹。

I've read that it is possible to get primefaces fileUpload to work with google appengine with a bit of tweaking. It requires apache fileupload and common io, so I added commons-fileupload-1.2.2.jar and commons-io-1.3.2.jar to my WEB-INF/lib folder.

然后按照primefaces的指示,我加了他们的servlet:

Then following the instructions of primefaces, I added their servlet:

<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    <init-param>
        <param-name>thresholdSize</param-name>
        <param-value>2147483647</param-value>
    </init-param>       
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>  

该thresholdSize放在故意高,因为它是由哪些文件会被保存到磁盘上,而不是在内存中保留它的字节数,以及由于没有文件可以使用谷歌的AppEngine被保存,它永远是一种选择。

The thresholdSize is put purposefully high because it is the number of bytes by which the file will be saved to disk rather than retain it in memory, and since no files can be saved using google appengine, it can never be an option.

的实际使用情况如下:

<h:form enctype="multipart/form-data">
    <!-- Other text fields go here -->
    <p:fileUpload fileUploadListener="#{tjBean.onHandleFileUpload}"  
        mode="advanced"  
        update=":toolbarForm:globalMessages"  
        sizeLimit="500000"   
        allowTypes="/(\.|\/)(txml)$/" /> 
<p:commandButton value="Okay" ajax="false" actionListener="#{tjBean.onSaveAction}" />
</h:form>

我了解,命令按钮不得使用AJAX,它必须​​是一个完整的页面重载。这似乎让我上传的文件顺利,但从来没有ActionListener的被触发。然后提交与命令按钮的形式引发异常:

I've understood that the commandButton must not use ajax and that it must be a full page reload. It seems to let me upload the file without a hitch, but the actionListener never gets triggered. Submitting then the form with the commandButton triggers an exception:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.commons.fileupload.disk.DiskFileItem
    at org.apache.commons.fileupload.disk.DiskFileItemFactory.createItem(DiskFileItemFactory.java:199)
    at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:361)
...

我不知道我在做什么错,还是我根本没有得到Apache库的版本适当,使这项工作正常。我使用primefaces的版本是3.2。当我寻找一个解决这个问题,共同应对是,谷歌的AppEngine不喜欢,我试图将文件保存到磁盘的事实,解决的方法就是提高门槛,但门槛高,因为它可以,所以它甚至不应该的尝试的将文件保存到磁盘。

I'm not sure what I'm doing something wrong or I simply did not get the appropriate versions of the apache libraries to make this work properly. The version of primefaces that I'm using is 3.2. When I search for a solution to this problem, the common response is that google appengine doesn't like the fact that I'm trying to save a file to the disk, and the solution is simply to increase the threshold, but the threshold is as high as it can be, so it shouldn't even be attempting to save the file to disk.

我倒是AP preciate任何帮助或建议,特别是如果该解决方案是昭然若揭了,我还没有看到它。先谢谢了。

I'd appreciate any help or suggestions, especially if the solution is glaringly obvious and I have yet to see it. Thanks in advance.

推荐答案

通过重写DiskItem为Apache文件上传库1.2.2解决了这一问题。

Fixed the problem by overriding DiskItem for Apache fileupload library 1.2.2.

具体评论静态字符串的UID(使用黑名单类java.rmi.server.UID中)和write方法的全部内容(我会设置门槛高,所以它不应该需要调用它)。

Specifically, commented static String UID (which uses blacklisted class java.rmi.server.UID) and entire contents of write method (I'll set threshold high so it should never require to call it).

显然,这不是理想的解决方案,但它会工作,只要我不需要更新文件上传库,我怀疑我需要在不久的将来。

Obviously it's not the ideal solution, but it will work so long as I don't need to update file upload library, which I doubt I'll need to in the near future.

这篇关于获取primefaces号码:文件上传到谷歌下工作的AppEngine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆