jsf - 调用 Request.getParts 时无需进行多部分配置。将 @MultipartConfig 添加到 servlet,或者将 multipart-config 元素添加到 web.xml

标签 jsf file-upload jsf-2.2

我想使用 JSF native 文件上传组件。如果可能的话使用 AJAX。但我无法让它工作。

文件上传

<h:form enctype="multipart/form-data">
    <h:inputFile value="#{bean.file}" required="true"/>
    <h:commandButton action="#{bean.importFile()}"/>
</h:form>

我认为使用 JSF 2.2 不应出现以下错误。

Request.getParts is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml

环境

  • 玻璃鱼4.1
  • 莫贾拉 2.2.4
  • Primefaces 5.0

最佳答案

由于某些[不明显]的原因,添加到 JSF-2.2 的 FacesServlet 中的 @MultipartConfig 并没有为您发挥作用。因此,您现在需要 manually add the multipart configuration to your web.xml像这样:

 <multipart-config>
      <location>/tmp</location>
      <max-file-size>20848820</max-file-size>
      <max-request-size>418018841</max-request-size>
      <file-size-threshold>1048576</file-size-threshold>
 </multipart-config>

关于jsf - 调用 Request.getParts 时无需进行多部分配置。将 @MultipartConfig 添加到 servlet,或者将 multipart-config 元素添加到 web.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26205024/

相关文章:

java - Facelet获取对象属性

python - swfupload 和 django 上的 403 禁止错误

java - JSF 2.2 流程和 Tomcat 7 java.lang.NoClassDefFoundError : javax/enterprise/context/spi/Context

jsf - Primefaces 数据表的列标题中的工具提示

jsf - FacesContext.getCurrentInstance().getExternalContext().redirect 不会立即重定向

PHP 文件上传 : keep both files if same name

jsf - 如何在 JSF 2 中进行分页

jsf - 迁移到 JSF 2.2 后 namespace 出现错误

java - Richfaces 4 + JBoss 6 = 部署异常

c# - FileUpload - 验证是否上传了实际文件