Jsf 请求没有';不包含多部分/表单数据或多部分/混合流

Jsf 请求没有';不包含多部分/表单数据或多部分/混合流,jsf,file-upload,primefaces,Jsf,File Upload,Primefaces,我正在尝试使用simple fileuploader上载文件,但不断出现以下错误: 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-ur

我正在尝试使用simple fileuploader上载文件,但不断出现以下错误:

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
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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">
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
        <init-param>
            <param-name>thresholdSize</param-name>
            <param-value>40960</param-value>
        </init-param>
        <init-param>
            <param-name>uploadDirectory</param-name>
            <param-value>/home/alen/uploads</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <context-param>
            <param-name>primefaces.THEME</param-name>
            <param-value>bootstrap</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

如果我使用高级文件上传器,那么一切都可以,但我需要简单的文件上传器,无法让它工作。我不知道怎么解决这个问题。有人能帮我解决这个问题吗?

JSF和PrimeFaces之间可能存在版本不兼容问题。您会使用什么版本的JSF和PrimeFaces?顺便说一句,你没有在你的真实代码中错误地嵌套表单吗?@Tiny JSF 2.2和PrimeFaces 5。0@Tiny是的,实际上是嵌套表单,我没有看到。很抱歉提出了一个愚蠢的问题,但这是我第一次使用PrimeFaces。这不是PrimeFaces相关的问题。嵌套表单在HTML中无效。在深入研究产生HTML代码的服务器端语言之前,您可能需要花更多的时间学习基本的HTML。
<h:form enctype="multipart/form-data">
    <h:panelGrid columns="1" style="width:100%;" class="imageUploadTable">
        <p:fileUpload value="#{objave.file}" mode="simple"/>

        <f:facet name="footer">

            <p:commandButton actionListener="#{objave.spremiSliku()}"
                             value="Spremi"
                             icon="ui-icon-disk"
                             ajax="false"/>
        </f:facet>
    </h:panelGrid>
</h:form>
private UploadedFile file;

public String spremiSliku() {
    System.out.println(file.getFileName());
    return "";
}