Fileupload和PrettyFaces和JSF

Fileupload和PrettyFaces和JSF

本文介绍了Fileupload和PrettyFaces和JSF 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下解决方案:


但是对于少数文件(在tomcat 7.0.50下测试)不起作用。 p>

其中一个文件是:


有人为这个问题提供了一个更好的解决方案(除去urlmap) ?

编辑:
没有错误/异常抛出!
文件显示在PrimeFaces FileUpload中,但是侦听器没有被触发!
JSF2.2 inputFile也不行!

解决方案

我找到了解决方案。

问题是用于上传的表单的action属性。
PrettyFaces将action属性更改为新的漂亮url。



如果将action属性更改为真实url(使用.xhtml,.jsf ,...)fileupload再次工作,上下文文件(tomcat)中的allowCasualMultipartParsing =true条目不再需要。

更改路径位置这个脚本进入视图(你的xhtml文件; jquery需要):

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

现在的文件上传正在为我的所有文件,包括它没有工作(即使allowCasualMultipartParsing =的那些真正的解决方案)。

用Primefaces4.0 FileUpload-Component测试。
$ b编辑:

>
还有其他更好的解决方案吗?


I've tried the solution from:Primefaces FileUpload with PrettyFaces and JSF 2.2.3

But it doesn't work for a few files (tested under tomcat 7.0.50).

One of the files is:http://ftp.carnet.hr/misc/apache//xerces/j/source/Xerces-J-src.2.11.0-xml-schema-1.1-beta.zip

Has someone a better solution for this problem (other than removing the urlmapping)?

EDIT:There is no error/exception thrown!File is shown in the PrimeFaces FileUpload, but the listener is not fired!JSF2.2 inputFile doesn't work, too!

解决方案

I've found a solution for my problem.

The problem is the action attribute of the forms which are used for the upload.PrettyFaces changes the action attribute to the new pretty-url.

If you change the action attribute to the real url (the one with .xhtml,.jsf,...) the fileupload works again and the allowCasualMultipartParsing="true" entry in the context-file(tomcat) is not needed anymore.

To change the path place this script into the view (your xhtml-file; jquery needed):

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

Now the fileupload is working for all of my files including the ones which not worked (even with allowCasualMultipartParsing="true" solution).

Tested with Primefaces4.0 FileUpload-Component.

EDIT:
Is there any other better solution?

这篇关于Fileupload和PrettyFaces和JSF 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 03:08