我有以下表单,通过 <h:inputFile>
上传文件和<f:ajax>
。
<h:form enctype="multipart/form-data">
<h:inputFile id="file" value="#{bean.file}" />
<h:commandButton value="Upload" action="#{bean.upload}">
<f:ajax execute="file" render="file" />
</h:commandButton>
</h:form>
当我提交它时,我收到一条 JavaScript 警报,其中包含以下错误信息:
serverError: class javax.servlet.ServletException the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is application/x-www-form-urlencoded;charset=UTF-8
这个问题有解决办法吗?我正在使用 Mojarra 2.2.11。
最佳答案
我转载了。这是 Mojarra 中的一个错误,在 2.2.9 中引入,作为修复 issue 3129 的副作用。 。您的问题已报告为 issue 3765 。基本上:自 Mojarra 2.2.9 起,使用 ajax 上传文件就被破坏了,并且没有解决方法(至少在代码中没有破解)。
目前,您需要降级到 Mojarra 2.2.8,直到他们发布包含修复程序的版本。
关于ajax - javax.servlet.ServletException 请求不包含多部分/表单数据或多部分/混合流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30791772/