简体   繁体   English

JSF 2.2,带有f:ajax的h:inputFile组件

[英]JSF 2.2, h:inputFile component with f:ajax

When I use h:inputFile with f:ajax and try to deploy it on Apache-tomcat-7.0.8 , the following exception is thrown by the tomcat server when the AJAX request is sent. 当我将h:inputFilef:ajax一起使用并尝试将其部署在Apache-tomcat-7.0.8上时 ,当AJAX请求发送时,tomcat服务器会引发以下异常。 Can any one please help me to fix this issue. 谁能帮我解决这个问题。 Thanks. 谢谢。

javax.servlet.ServletException on Tomcat Tomcat上的javax.servlet.ServletException

com.sun.faces.renderkit.html_basic.FileRenderer decode
SEVERE: Unable to get parts for frmIndex:file
javax.servlet.ServletException: 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;charset=UTF-8

JSF Page JSF页面

<h:form id="frmIndex" enctype="multipart/form-data">

   <h:inputFile id="file" value="#{indexController.file}"/>

   <h:commandButton value="Upload" action="#{indexController.postTrailDetail}">
      <f:ajax execute=":frmIndex:tUpostPanelGroup" render="@all"/>
   </h:commandButton>

</h:form>

Java Controller Java控制器

@Component
@SessionScoped
@Scope("session")
@Qualifier("indexController")
public class IndexController implements Serializable {

  private Part file;

  public void postTrailDetail() {

   if(file != null) {} 

  }

  // Getter and Setter for Part

}

Maven dependencies Maven依赖

       <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.0-m03</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.0-m03</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

Try without f:ajax tag? 尝试不使用f:ajax标签吗? I have problem eith this tag and error message when use ajax. 我在使用ajax时遇到这个标签和错误消息的问题。 Without ajax every is fine. 没有ajax,一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM