我点击提交表格,tomcat lance exception
ps:点击提交测试,而不是上传文件(pdf)
ps2:我在表单中有表格(姓名,电话,电话2,电子邮件,预科)
primefaces 4.0 upload.jar 1.3 io.jar 2.4
Out 17, 2013 8:13:08 AM com.sun.faces.lifecycle.ApplyRequestValuesPhase execute
Advertência: javax.servlet.ServletException: org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/form-data 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/form-data 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.UIForm.processDecodes(UIForm.java:225)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:929)
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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
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:724)
Caused by: javax.servlet.ServletException: org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header is application/x-www-form-urlencoded; charset=UTF-8
at org.apache.catalina.connector.Request.parseParts(Request.java:2786)
at org.apache.catalina.connector.Request.getParts(Request.java:2640)
at org.apache.catalina.connector.Request.getPart(Request.java:2810)
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)
... 30 more
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/form-data 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:806)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:261)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:285)
at org.apache.catalina.connector.Request.parseParts(Request.java:2722)
... 35 more
Out 17, 2013 8:13:08 AM com.sun.faces.context.AjaxExceptionHandlerImpl handlePartialResponseError
Grave: javax.servlet.ServletException: org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/form-data stream, content type header is application/x-www-form-urlencoded; charset=UTF-8
at org.apache.catalina.connector.Request.parseParts(Request.java:2786)
at org.apache.catalina.connector.Request.getParts(Request.java:2640)
at org.apache.catalina.connector.Request.getPart(Request.java:2810)
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)
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.UIForm.processDecodes(UIForm.java:225)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1220)
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:929)
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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
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:724)
Caused by: org.apache.tomcat.util.http.fileupload.FileUploadBase$InvalidContentTypeException: the request doesn't contain a multipart/form-data or multipart/form-data 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:806)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.getItemIterator(FileUploadBase.java:261)
at org.apache.tomcat.util.http.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:285)
at org.apache.catalina.connector.Request.parseParts(Request.java:2722)
... 35 more
我的代码xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:body>
<ui:composition template="/template/template.xhtml">
<ui:param name="bean" value="#{segundaChamadaProvaBean}" />
<ui:define name="cabecalho">
<ui:include src="/template/topo.xhtml" />
</ui:define>
<ui:define name="corpo">
<h:form id = "formulario" enctype="multipart/form-data">
<br/><br/>
NOS TERMOS DO REGIMENTO INTERNO REQUER 2º CHAMADA DAS DISCIPLINAS
ABAIXO, CONFORME <b>ORIGINAL DO ATESTADO MÉDICO ANEXO E REFERENTE À:</b>
<h:panelGrid columns="1">
<p:outputLabel for="uploadFile" value = "Anexar:"/>
<p:fileUpload fileUploadListener="#{fileBean.handleFileUpload}"
id="uploadFile"
mode="advanced"
label="Procurar..."
uploadLabel="Carregar"
cancelLabel="Cancelar"
dragDropSupport="true"
fileLimit="1"
fileLimitMessage="Limite máximo de upload 1."
invalidSizeMessage="Tamanho máximo 20mb"
sizeLimit="20971520"
allowTypes="/(\.|\/)(pdf)$/"
required="true"
invalidFileMessage="Arquivo inválido somente é aceito pdf."
requiredMessage="Porfavor fazer upload de documento."
auto="true"
/>
</h:panelGrid>
Concordo com os termos acima.
<p:selectBooleanCheckbox id = "concordoTermos" value = "#{segundaChamadaProvaBean.concordoAcima}">
<p:ajax event="change" process = "concordoTermos avaliacao" update="btnEnviar" listener="#{segundaChamadaProvaBean.liberaBotaoEnviar()}"></p:ajax>
</p:selectBooleanCheckbox>
<br/>
<p:commandButton id = "btnEnviar" disabled="#{!segundaChamadaProvaBean.concordoAcima}" value="Enviar" action="#{segundaChamadaProvaBean.testa()}" update="formulario"/>
<br />
<br />
<b>GOIÂNIA, <h:outputLabel value = "#{segundaChamadaProvaBean.dataAtual}">
<f:convertDateTime dateStyle="medium"/>
</h:outputLabel></b>
<br/>
<h6>1. PREENCHER O REQUERIMENTO DE 2º CHAMADA, MEDIANTE O ORIGINAL DO ATESTADO MÊDICO ANEXO<br/>
2. DEVOLVER O REQUERIMENTO AO PROTOCOLO GERAL, SOB PENA DE SER ENVALIDADO</h6>
</fieldset>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
的web.xml
<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>Faculdade</display-name>
<!--
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
-->
<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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
如果有人帮忙..
答案 0 :(得分:3)
我遇到了同样的问题,在我停止使用ajax提交表单后它就消失了。你需要:
<p:commandButton id = "btnEnviar" disabled="#{!segundaChamadaProvaBean.concordoAcima}" value="Enviar" action="#{segundaChamadaProvaBean.testa()}" update="formulario" ajax="false" />
答案 1 :(得分:0)
在表单上使用此选项:
<h:form enctype="multipart/form-data">