1
我有一個簡單的上傳文件的形式,它顯示了帶有tmp擴展名的文件名,但沒有顯示上傳文件的實際名稱。文件名不顯示上傳文件的名稱
JSP
<s:form id="uploadCSV" method="POST" action="add" enctype="multipart/form-data">
<s:file name="csv" label="Upload File"/>
<s:submit/>
</s:form>
的Java
private File csv;
private String contentType;
private String fileName;
private String filename;
private String FileName;
private String Filename;
..... all getter setters here .....
System.out.println("file:" + fileName); <<null
System.out.println("Name >>>>" + this.csv.getName()); << upload_344f45f4f54f5f5_54r5r4000.tmp
System.out.println("Name >>>>" + this.contentType); << null
System.out.println("Name >>>>" + this.FileName); << null
System.out.println("Name >>>>" + this.Filename); << null
System.out.println("Name >>>>" + this.filename); << null
也許'fileInputFromForm'優於'formName'。 :) –
@AleksandrM是的,這是更合適。更新。謝謝。 –