简单的Jetty / JSF文件上传不会提交

问题描述 投票:0回答:1

[I've already looked at this one和相关票证无济于事。

我有,看起来像是最简单的例子

<h:form enctype="multipart/form-data"  prependId="false">
<h:outputText value="File: "></h:outputText>
<h:inputFile value="#{configUploadController.uploadedFile}"  />
<h:commandButton value="Save" type="submit" action="#{configUploadController.uploadFile}" style="color: red;"></h:commandButton>
</h:form>

我在uploadFile方法中添加了一个断点,但是它从来没有被击中。当我从表单中删除enctype时,它确实尝试提交,但随后出现了明显的错误...

javax.servlet.ServletException: Content-Type != multipart/form-data

[为了完整起见,我删除了<h:inputFile>enctype,可以看到断点被击中。当我将enctype设置为text/plain时,它DOESNT达到了断点。但是,当我将enctype设置为乱码时,[[DOES命中了断点:(

我在某处缺少依赖项或配置吗?

如果有关系的话,我的web.xml ...

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <!-- File(s) appended to a request for a URL that is not mapped to a web component --> <welcome-file-list> <welcome-file>status.xhtml</welcome-file> </welcome-file-list> <context-param> <param-name>com.sun.faces.expressionFactory</param-name> <param-value>com.sun.el.ExpressionFactoryImpl</param-value> </context-param> <listener> <description>Initializes Oracle JSF</description> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <!-- Define the JSF servlet (manages the request processing life cycle for JavaServer Faces) --> <servlet> <servlet-name>faces-servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <!-- Map following files to the JSF servlet --> <servlet-mapping> <servlet-name>faces-servlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> </web-app>

    jsf-api-2.2.15
  • jsf-impl-2.2.15
  • el-api-2.2
  • el-impl-2.2
  • 码头9.4.18
  • javax.servlet-api-3.1.0
jsf jetty
1个回答
0
投票
所以,我没有花时间去追查为什么,但是码头似乎并不喜欢多部分的形式。我通过使用servlet解决了这个问题。解决方案看起来像这样...

我已经使用了ajax方法和HTML表单,所以我可以指定与servlet模式匹配的操作...

© www.soinside.com 2019 - 2024. All rights reserved.