Primefaces5向导组件& JSF2.2.7文件上传不起作用?

时间:2014-08-05 08:40:17

标签: jsf file-upload primefaces wizard

我在我的网络应用程序中使用PF5.0和JSF2.2.7,使用primefaces Wizard Component进行文件上传,这样

   <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:p="http://primefaces.org/ui"
        template="./../templates/loggedinTemplate.xhtml">

        <ui:define name="title">Group Distribution </ui:define>

        <ui:define name="moduleDetails">

            <h:form enctype="application/x-www-form-urlencoded; charset=UTF-8" >

                <p:growl id="growl" sticky="true" showDetail="true" />
                <p:overlayPanel for="helpButton" hideEffect="fade"
                    style="float: right; width: 50%">
                    <p:panel header="3 Step Process" style="width:97%;">

                        <p:spacer height="40"></p:spacer>
                        <h:outputText value="Step 1" styleClass="linkButton"
                            style="background-color: #0165b0 !important" />
                        <h:outputText style="font-size:12px;" value=" Upload XSL File" />
                        <br />
                        <p:spacer height="40"></p:spacer>
                        <h:outputText value="Step 2" styleClass="linkButton"
                            style="background-color: #0165b0 !important" />
                        <h:outputText style="font-size:12px;"
                            value="Check Length and make changes" />
                        <br />
                        <p:spacer height="40"></p:spacer>
                        <h:outputText value="Step 3" styleClass="linkButton"
                            style="background-color: #0165b0 !important" />
                        <h:outputText style="font-size:12px;" value="Save Tweets" />
                    </p:panel>
                </p:overlayPanel>

                <f:facet name="actions">
                    <p:commandLink value="Help" id="helpButton" type="button"
                        styleClass="ui-panel-titlebar-icon" />
                </f:facet>


                <p:spacer height="20"></p:spacer>
                <p:wizard widgetVar="fileUploadWiz" nextLabel="Next"
                    flowListener="#{tweetDistributionManagedBean.onFlowProcess}"
                    showStepStatus="true">>
                    <p:tab id="upload" title="Upload File" styleClass="main">
                        <p:panel style="width:100%" styleClass="panelnoborder">
                            <f:facet name="header">
                                <p:outputLabel styleClass="mainTitlebar"
                                    value="Step 1. Upload XSL File"></p:outputLabel>
                            </f:facet>

                            <p:spacer height="10" width="100%"></p:spacer>
                            <h:outputText
                                value="If transactions are in an Excel spreadsheet, then first save the sheet as CSV file and then upload. Download " />
                            <p:commandLink id="downloadLink" value="Sample Xls File"
                                ajax="false" style="font-size:12px;color:#F62217 !important">
                                <p:fileDownload
                                    value="#{tweetDistributionManagedBean.downloadFile}" />
                            </p:commandLink>

                            <p:spacer height="20" width="100%"></p:spacer>

                            <p:panelGrid align="centre" style="width:100%" cellspacing="5">

                                <p:row>
                                    <p:column>
                                        <p:fileUpload
                                            style="font-size:12px;background-color: #FC8C02 !important;align:centre;"
                                            fileUploadListener="#{tweetDistributionManagedBean.handleFileUpload}"
                                            label="Choose File" showButtons="false"
                                            requiredMessage="Please select the file" required="true"
                                            mode="advanced" multiple="true" update="@form" auto="true"
                                            sizeLimit="1048576"
                                            allowTypes="/(\.|\/)(doc|docx|xls|xlsx|pdf)$/" />



                                    </p:column>

                                </p:row>
                                <p:row>
                                    <p:column>

                                        <h:outputText
                                            value="#{tweetDistributionManagedBean.fileUploadMessage}"></h:outputText>
                                    </p:column>
                                </p:row>

                            </p:panelGrid>
                        </p:panel>
                    </p:tab>
                    <p:tab title="Edit Tweets" styleClass="main">
                        <p:panel>
                            <f:facet name="header">
                                <p:outputLabel styleClass="mainTitlebar"
                                    value="Step 2. Edit Tweets"></p:outputLabel>
                            </f:facet>
                            <h:panelGrid columns="1" cellpadding="10" cellspacing="5"
                                style="width:700px;" columnClasses="label, value">
                                <p:column>
                                    <p:dataTable  
                                        value="#{tweetDistributionManagedBean.excellist}" var="o"
                                        resizableColumns="true" styleClass="ui-datatable-hor-scroll"
                                        scrollWidth="100%" tableStyle="width:auto" rowKey="#{o}">


                                        <p:column headerText="Tweet Id">

                                            <h:outputText value="#{o.distObject.gdId}" />


                                        </p:column>

                                        <p:column headerText="Tweet"> 

                                            <h:inputText value="#{o.distObject.gdTweet}" size="20" />

                                        </p:column>



                                    </p:dataTable>
                                </p:column>
                                <p:spacer></p:spacer>
                                <p:commandButton value="Submit"
                                    actionListener="#{groupWizardBean.saveGroup}" update="growl" />
                            </h:panelGrid>
                        </p:panel>
                    </p:tab>
                </p:wizard>


            </h:form>

        </ui:define>

</ui:composition>

但是当我点击“下一步”按钮上传文件后,它正在抛出

 INFO: javax.faces.FacesException: 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 javax.faces.FacesException:
 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  at
 org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:44)
    at
 org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:44)
    at
 javax.faces.component.UIComponentBase.decode(UIComponentBase.java:831)
    at javax.faces.component.UIInput.decode(UIInput.java:771)   at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1225)
    at javax.faces.component.UIInput.processDecodes(UIInput.java:676)   at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 org.primefaces.component.panel.Panel.processDecodes(Panel.java:280)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 org.primefaces.component.wizard.Wizard.processDecodes(Wizard.java:179)
    at
 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:573)
    at
 com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)  at
 javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)     at
 javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)     at
 com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
    at
 com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:266)
    at
 javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)
    at
 org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
    at
 javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:927)
    at
 com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)   at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at
 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at
 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at
 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at
 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at
 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722) Caused by:
 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  at
 org.apache.catalina.connector.Request.parseParts(Request.java:2772)
    at org.apache.catalina.connector.Request.getParts(Request.java:2631)
    at org.apache.catalina.connector.Request.getPart(Request.java:2796)
    at
 org.apache.catalina.connector.RequestFacade.getPart(RequestFacade.java:1082)
    at
 org.primefaces.component.fileupload.NativeFileUploadDecoder.decodeAdvanced(NativeFileUploadDecoder.java:60)
    at
 org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:37)
    ... 53 more Caused by:
 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  at
 org.apache.tomcat.util.http.fileupload.FileUploadBase$FileItemIteratorImpl.<init>(FileUploadBase.java:774)
    at
 org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:284)
    at
 org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:304)
    at
 org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload.parseRequest(ServletFileUpload.java:129)
    at
 org.apache.catalina.connector.Request.parseParts(Request.java:2713)
    ... 58 more

 Aug 05, 2014 1:48:27 PM
 com.sun.faces.lifecycle.ApplyRequestValuesPhase execute WARNING:
 javax.faces.FacesException: 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 javax.faces.FacesException: javax.faces.FacesException:
 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  at
 com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:273)
    at
 javax.faces.context.PartialViewContextWrapper.processPartial(PartialViewContextWrapper.java:219)
    at
 org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:60)
    at
 javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:927)
    at
 com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)    at
 com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)   at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:145)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at
 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at
 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at
 org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
    at
 org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
    at
 org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
    at
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722) Caused by:
 javax.faces.FacesException: 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  at
 org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:44)
    at
 org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:44)
    at
 javax.faces.component.UIComponentBase.decode(UIComponentBase.java:831)
    at javax.faces.component.UIInput.decode(UIInput.java:771)   at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1225)
    at javax.faces.component.UIInput.processDecodes(UIInput.java:676)   at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 org.primefaces.component.panel.Panel.processDecodes(Panel.java:280)
    at
 javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
    at
 org.primefaces.component.wizard.Wizard.processDecodes(Wizard.java:179)
    at
 com.sun.faces.context.PartialViewContextImpl$PhaseAwareVisitCallback.visit(PartialViewContextImpl.java:573)
    at
 com.sun.faces.component.visit.PartialVisitContext.invokeVisitCallback(PartialVisitContext.java:183)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1689)
    at javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)
    at javax.faces.component.UIForm.visitTree(UIForm.java:371)  at
 javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)     at
 javax.faces.component.UIComponent.visitTree(UIComponent.java:1700)     at
 com.sun.faces.context.PartialViewContextImpl.processComponents(PartialViewContextImpl.java:403)
    at
 com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:266)
    ... 32 more Caused by: 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  at
 org.apache.catalina.connector.Request.parseParts(Request.java:2772)
    at org.apache.catalina.connector.Request.getParts(Request.java:2631)
    at org.apache.catalina.connector.Request.getPart(Request.java:2796)
    at
 org.apache.catalina.connector.RequestFacade.getPart(RequestFacade.java:1082)
    at
 org.primefaces.component.fileupload.NativeFileUploadDecoder.decodeAdvanced(NativeFileUploadDecoder.java:60)
    at

任何人都可以告诉我我缺少哪些更改和配置?

0 个答案:

没有答案