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>

爪哇

    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
4

1 回答 1

2

将以下必填成员字段添加到您的操作。

private String csvFileName;
private String csvContentType;

我想你现在可以很容易地弄清楚命名方案。

private File <fileInputFormName>;

private String <fileInputFormName>FileName;
private String <fileInputFormName>ContentType;
于 2013-05-27T00:57:10.730 回答