0
不知道如何进行调试。我有一个行为不端的PrimeFaces fileUpload组件。PrimeFaces fileUpload组件进度条失败
- 我与PrimeFaces 3.5工作
- FileUpload组件进度条在文件上传过程中不显示进度
- 文件并上传成功
- 没有看到错误消息,在我的IDE错误控制台
- 我也没有看到在浏览器控制台中的任何JavaScript错误
- 这确实有一段时间(我继承了这个项目),试图通过我的git回购找到什么改变,但没有运气
这里是我的组件代码
<div class="input input-file">
<p:fileUpload fileUploadListener="#{adminFilesController.handleFileUpload}"
mode="advanced"
process="@form"
multiple="true"
allowTypes="/(\.|\/)(gif|jpe?g|png|mp4|avi)$/"
/>
</div>
这是它说话
public void handleFileUpload(FileUploadEvent event) {
try {
String fileName = event.getFile().getFileName();
String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
String randomId = UUID.randomUUID().toString();
String targetFileName = randomId + "." + fileExtension;
File targetFile = new File(this.tempPath, targetFileName);
this.uploadedFiles.put(targetFileName, fileName);
InputStream inputStream = event.getFile().getInputstream();
OutputStream out = new FileOutputStream(targetFile);
int read = 0;
byte[] bytes = new byte[20480];
try {
while ((read = inputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
inputStream.close();
out.flush();
out.close();
} catch (Exception e) {
logger.log(Level.SEVERE, "Can't write file", e.toString());
}
} catch (Exception e) {
logger.log(Level.SEVERE, "An exception occurred trying to process the handleFileUpload Event {0}", e.toString());
logger.log(Level.SEVERE, e.getMessage());
System.out.println(e.getStackTrace());
}
}
任何援助调试或谷歌搜索,这将是一笔巨额赞赏法,我是一个当涉及到JSF和PrimeFaces时,耳朵后面很小。
什么版本的Primefaces? –
PrimeFaces v 3.5 @ DanielB.Chapman。 – fusion27