提问人:mtmx 提问时间:11/7/2023 更新时间:11/7/2023 访问量:14
Primefaces 迁移:org.primefaces.util.FileUploadUtils.isValidType 无法验证上传文件的类型
Primefaces migration: org.primefaces.util.FileUploadUtils.isValidType The type of the uploaded file could not be validated
问:
我正在将Primefaces 6.2迁移到7.0,但遇到了以下问题: 这是我用于文件上传的组件
<p:fileUpload id="fileupload"
label="#{msg['page.application-decisions.selectFile']}"
value="#{decisionBean.uploadedFile}"
style="display: flex; "
styleClass="button like-link font-14 -margin-bottom-20"
mode="advanced"
multiple="false"
auto="true"
dragDropSupport="false"
allowTypes="/(\.|\/)(pdf)$/"
sizeLimit="10000000"
invalidSizeMessage="#{msg['page.application-decisions.invalidSizeMessage']}"
invalidFileMessage="#{msg['page.application-decisions.invalidFileMessage']}"
fileLimitMessage="#{msg['page.application-decisions.fileLimitMessage']}"
fileUploadListener="#{decisionBean.handleFileUpload}"
disabled="#{decisionBean.application.anyDecisionNotNotified==true}"
update="filemsg fileupload uploadedFileName @this">
</p:fileUpload>
在 Pf 6.2 组件上正确上传文件,但在 PF 7.0 中,我遇到堆栈跟踪错误:
07-Nov-2023 10:28:39.858 WARNING [http-nio-8080-exec-3] org.primefaces.util.FileUploadUtils.isValidType The type of the uploaded file attachmentExample.pdf could not be validated
javax.script.ScriptException: java.lang.NullPointerException: JavaScript ScriptEngine not available via the context ClassLoader or the extension ClassLoader.
at org.primefaces.util.FileUploadUtils.isValidFileName(FileUploadUtils.java:177)
at org.primefaces.util.FileUploadUtils.isValidType(FileUploadUtils.java:145)
at org.primefaces.component.fileupload.NativeFileUploadDecoder.isValidFile(NativeFileUploadDecoder.java:118)
at org.primefaces.component.fileupload.NativeFileUploadDecoder.decodeAdvanced(NativeFileUploadDecoder.java:111)
at org.primefaces.component.fileupload.NativeFileUploadDecoder.decode(NativeFileUploadDecoder.java:56)
at org.primefaces.component.fileupload.FileUploadRenderer.decode(FileUploadRenderer.java:60)
at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:832)
at javax.faces.component.UIInput.decode(UIInput.java:773)
如果我删除allowTypes参数,则没有错误,但我需要验证.pdf扩展名
答: 暂无答案
评论