tomahawk inputfileupload 上传的文件为空
我正在使用 Tomahawk 的文件上传组件
来上传文件。我已将表单的 enctype 设置为
enctype="multipart/form-data"
,并使用
提交表单。
但 bean 中的 UploadedFile
属性为 null
。我做错了什么以及如何解决它?
I am using Tomahawk's fileupload component <t:inputfileupload>
for uploading files. I've set enctype of form as
enctype="multipart/form-data"
and I used <h:commandButton>
to submit the form.
But the UploadedFile
property in the bean is null
. What am I doing wrong and how can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保您已按照他们的文档配置了
ExtensionsFilter
。它负责处理multipart/form-data
请求并将适当的部分设置为 bean 属性。另请参阅:
Ensure that you've configured the
ExtensionsFilter
as per their documentation. It's the one responsible for processingmultipart/form-data
requests and setting the appropriate parts as bean properties.See also:
确保您没有使用嵌套表单。因为上传组件不以嵌套形式运行。
它将抛出空指针异常。
Ensure that you are not using nested forms. Because upload component dont run in nested forms.
It will throw null pointer exception.
当我开始基于面孔扩展时,我遇到了这个问题 -> 的内容
您放置
<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
并使用 myfaces-extensions-1.0.9 。罐。
onjava.com 有一个关于该方法的教程 但该教程是 2005 年的,不适用于当前的 jsf1.2 版本。在与谷歌找到的非常旧的解决方案教程进行斗争时,我意识到值得始终检查您是否正在使用最新的教程,而不仅仅是最新的 jar 版本。
我想把这个解决方案提供给那些也从头到尾开始做这件事的人。
I got this issue when I had started on the basis of faces extensions -> the stuff where you put
<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>
and use myfaces-extensions-1.0.9.jar.
There is a tutorial on that approach at onjava.com but the tutorial is from year 2005 and does not work with the current jsf1.2 versions. Being fighting with that very old solution tutorial found with google I realized it's worth of checking always that you're using uptodate tutorials also not just uptodate jar-versions.
I wanted to give this solution to those who also have started this thing from upside down.