在这种情况下,它工作正常,上传文件没有问题(在我编辑 web.xml 添加过滤器和 faces-confing 添加依赖项之前):
<h:form id="form1">
<p:messages id="messages" showDetail="true" autoUpdate="true" />
<p:panel header="Iniciar sesión" style="width:300px;height:150px;">
<h:panelGrid columns="2" id="matchGrid">
<h:outputLabel for="pwd1" value="Usuario: *" />
<p:inputText id="pwd1" value="#{loginMB.usuario}" label="usuario"
required="true" />
<h:outputLabel for="pwd2" value="Clave: *" />
<p:password id="pwd2" value="#{loginMB.clave}" label="clave"
required="true" />
</h:panelGrid>
<p:commandButton id="saveButton" action="#{loginMB.login}"
update="matchGrid" value="Entrar" />
</p:panel>
</h:form>
<h:form enctype="multipart/form-data">
<p:messages showDetail="true" />
<p:fileUpload value="#{contratosMB.fileContrato}" mode="simple" />
<p:commandButton value="Submit" ajax="false"
actionListener="#{contratosMB.upload}" />
</h:form>
但是当我把它放在另一个表单中时它不起作用,为什么?
<h:form id="form3sd">
<h:form id="form1">
<p:messages id="messages" showDetail="true" autoUpdate="true" />
<p:panel header="Iniciar sesión" style="width:300px;height:150px;">
<h:panelGrid columns="2" id="matchGrid">
<h:outputLabel for="pwd1" value="Usuario: *" />
<p:inputText id="pwd1" value="#{loginMB.usuario}" label="usuario"
required="true" />
<h:outputLabel for="pwd2" value="Clave: *" />
<p:password id="pwd2" value="#{loginMB.clave}" label="clave"
required="true" />
</h:panelGrid>
<p:commandButton id="saveButton" action="#{loginMB.login}"
update="matchGrid" value="Entrar" />
</p:panel>
</h:form>
<h:form enctype="multipart/form-data">
<p:messages showDetail="true" />
<p:fileUpload value="#{contratosMB.fileContrato}" mode="simple" />
<p:commandButton value="Submit" ajax="false"
actionListener="#{contratosMB.upload}" />
</h:form>
</h:form>