나는 sessionScoped 인 uploadBean을 가지고있다.JSF의 "multipart/form-data"폼에서 원격 명령을 호출하는 방법
<h:form enctype="multipart/form-data">
<p:fileUpload fileUploadListener="#{uploadBean.handleFileUpload}" mode="advanced"
allowTypes="/(\.|\/)(mdb)$/"
description="Select File"
dragDropSupport="true"
multiple="false"
fileLimit="1"
update="growl"
widgetVar="fileUploadWidget"
oncomplete="PF('fileUploadWidget').reset(); myRemoteFunction()"/>
<p:remoteCommand name="myRemoteFunction" action="#{uploadBean.remoteFunction}"/>
<script>
PrimeFaces.widget.FileUpload.prototype.reset = function() {
this.clearMessages();
return this.init(this.cfg);
}
</script>
</h:form>
콩 측면에서 : 나는 onComplete를에 원격 명령 myRemoteFunction
를 호출 할
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
: 나는 원격 명령 "myRemoteFunction"을 설정하면
public void remoteFunction(){
//some logic here after the file is uplodaded
}
public void handleFileUpload(FileUploadEvent event) {
//some growl messages are set here
// and let the progress bar vanish immediately
}
나는이 오류 메시지를 받았습니다
handleFileUpload 함수에서 remoteFunction을 호출하고 싶지 않습니다. 왜냐하면 내가 그것을 부를 때, 진행 막대는 파일이 완전히 업로드 된 것처럼 보여 주지만, 프로세스가 hadleFileUpload 함수를 빠져 나올 때까지 사라지지 않는다. 왜냐하면 remoteFuction의 로직은 5 초에서 15 초가 걸리기 때문입니다.
어떻게해야합니까? 감사.
재설정 기능을 사용하여 업로드 파일 한도를 재설정합니다 (사용자가 다른 파일을 업로드 할 수 있도록 재설정합니다). 불필요한 코드 블록을 제거하면 myRemoteFunction()의 괄호를 잊어 버릴 수 있습니다. 이것은 거의 원래의 코드 블록입니다. 다시 확인하십시오. – rLyLmZ