我不清楚渲染上傳Excel表單成JSP頁如何從Temp文件夾中呈現JSP頁面中上傳的Excel文件?
這裏是上載的Excel的示例代碼
importExcel.jsp
<body>
<form:form method="POST" action="fileUpload" enctype="multipart/form-data">
<div class="upload">
<div class="upload-files">
<header>
<p>
<i class="fa fa-cloud-upload" aria-hidden="true"></i>
<span class="up">up</span>
<span class="load">Load</span>
</p>
</header>
<div class="body" id="drop">
<i class="fa fa-file-text-o pointer-none" aria-hidden="true"></i>
<p class="pointer-none"><b>Drag and drop</b> files here <br /> or <a href="" id="triggerFile">browse</a> to begin the upload</p>
<input type="file" name="xlsFile" accept=".xls,.xlsx" />
</div>
<footer>
<div class="divider">
<span><AR>FILES</AR></span>
</div>
<div class="list-files">
<!-- template -->
</div>
<button class="importar">UPDATE FILE</button>
</footer>
</div>
</div>
</form:form>
</body>
HomeController.java
@PostMapping("/fileUpload")
public String getFileUploadResult(@RequestParam("xlsFile") MultipartFile multiPartFile)throws Exception{
try {
if(multiPartFile!=null && !multiPartFile.isEmpty()){
byte[] fileBytes = multiPartFile.getBytes();
if(fileBytes!=null){
System.out.println("multiPartFile.getOriginalFilename() :: " +multiPartFile.getOriginalFilename());
Path internalPath=Paths.get(RAW_DATA_FILE_PATH+multiPartFile.getOriginalFilename());
if(internalPath!=null){
System.out.println("file written");
Files.write(internalPath,fileBytes);
}else{
System.out.println("internalPath is null");
}
}else{
System.out.println("fileBytes is null");
}
}else{
return "importExcel";
}
} catch (Exception e) {
throw e;
}
return "viewUploadedExcel";
}
我需要在viewUploadedExcel.jsp文件中查看上傳的Excel文件,因爲我在這方面的研究推出瞭解決方案並沒有達到預期。
注意:我正在JSP和Spring
請問您遇到的問題具體問題是否實現了?你的問題是什麼?如何解析excel文件?如何渲染表格?你其實在這裏要求一個偏離主題的教程。更改問題以顯示您遇到的一些小問題並展示您的最大努力。 – StanislavL
嗨stanislavL,我的問題是如何查看JSP頁面中的Excel文件。由於我經歷了許多博客,我無法獲得解決方案。你能幫忙嗎 –
所描述的問題不適用於計算器。適合於SO的問題可以是例如「我嘗試用apache POI庫解析excel文件並得到錯誤...」。這是問題可以幫助解決。或者「我解析過文件並且有一個二維數組,不能將數組輸出到帶有rpoblem的JSP ......」。對於SO很好,可以回答。在你的情況下,它太廣泛了。把你的問題列在一個較小的問題列表中,並針對每個相對較小的問題發佈不同的問題。 – StanislavL