gpt4 book ai didi

jsf - p :fileUpload doesn't work inside p:dialog

转载 作者:行者123 更新时间:2023-12-02 14:13:57 27 4
gpt4 key购买 nike

我尝试在 p:dialog 中使用 PrimeFaces p:fileUpload 上传文件,但不起作用

<h:form id="form3"> 
<p:commandLink value="upload" oncomplete="PF('Dialog').show()" />
<p:dialog widgetVar="submitDialog" modal="true" >
<h:form id="form" enctype="multipart/form-data" >
<h:panelGrid id="submitPanelGrid" columns="2" >
<p:fileUpload id="upload" value="#{bean.file}" mode="simple" sizeLimit="100000" />
<p:commandButton id="btn3" action="#{bean.submit()}" icon="ui-icon-circle-check" ajax="false" />
</h:panelGrid>
</p:panel>
</h:form>
</p:dialog>
</h:form>

点击链接后,我收到此异常:

org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/mixed stream,
content type header is application/x-www-form-urlencoded;

但在外面<p:dialog> ,效果很好。

最佳答案

首先,html中不允许在另一个表单中使用另一个表单,您必须将对话框与主表单分开,对于您遇到的异常(exception)情况,您必须添加 enctype="multipart/form-data" 到您的对话框表单:

   <h:form id="form3"> 
<p:commandLink value="upload" oncomplete="PF('Dialog').show()" />
</h:form>

<p:dialog widgetVar="submitDialog" modal="true" >
<h:form id="form" enctype="multipart/form-data" >
<h:panelGrid id="submitPanelGrid" columns="2" >
<p:fileUpload id="upload" value="#{bean.file}" mode="simple" sizeLimit="100000" />
<p:commandButton id="btn3" action="#{bean.submit()}" icon="ui-icon-circle-check" ajax="false" />
</h:panelGrid>
</p:panel>
</h:form>
</p:dialog>

关于jsf - p :fileUpload doesn't work inside p:dialog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46187020/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com